谷歌 Summer Intern OA 2019

Given an int array nums of length n. Partition it into minimum number of strictly decreasing subsequences preserving the original order of elements.

Input: [2, 9, 12, 13, 4, 7, 6, 5, 10]
Output: 4
Explanation:
Possible partitions are
[2], [9], [12], [13, 4], [7, 6, 5], [10]
[2], [9, 4], [12, 10], [13, 7, 6, 5]
4 is the minimum so return 4.

Given two integer arrays houses and stores. Find the nearest store for every house. The distance between a store and a house is defined as abs(stores[i] - houses[i]). If there are multiple stores with the same min distance just output the smallest store.

Example 1:

Input: houses = [2, 4, 2], stores = [5, 1, 2, 3]
Output: [2, 3, 2]
Explanation:
houses[0] = 2, 2 is the store which has the minimal distance to 2
houses[1] = 4, 3 and 5 have the same distance to 4, output 3 because 3 is smaller
houses[2] = 2, same as houses[0]
Example 2:

Input: houses = [4, 8, 1, 1], stores = [5, 3, 1, 2, 6]
Output: [3, 6, 1, 1]
Explanation:
houses[0] = 4, 3 and 5 have the same distance to 4 so output 3 because 3 is smaller
houses[1] = 8, 6 is the store which has the minimal distance to 8
houses[2] = 1, 1 is the store which has the minimal distance to 1
houses[3] = 1, same as houses[2]

int[] nearestStores(int[] houses, int[] stores);

补充一个:

The distance between 2 binary strings is the sum of their lengths after removing the common prefix. For example: the common prefix of 1011000 and 1011110 is 1011 so the distance is len("000") + len("110") = 3 + 3 = 6 .

Given a list of binary strings, find the max distance between any 2 strings.