# Expedia OA

3 Problems, 90 minutes.

Problem 1

Adding sequence number to the end of the repeating names.

Input

[“tom”,“alex”,“jack”,“Alex”]

Ouput

[“tom”,“alex”,'jack",“alex1”]

Explanation

Name “alex” apears twice, the first one can be ignored, sequence number should be added from the second alex.

Solution

Count as you go in a HashMap and ignore the first index 0.

Problem 2

Take out the given number of elements in the list so that the uniqueness is low.

Input

ids = [1,2,3,1,2,2] m=3

Output

1

Explanation

We can remove 3, 1, 1 and leave only 2 from the input array. Where 1 represents the number of unique number left in the list. In this case, it is 1.

Solution

1. Create a class Item with property count and id. id here is the number from the input array.

2. Count all the unique elements via a HashMap, once it is done output them in a List. Sort it in desending order.

3. From the end, decrease the count while m–. When count is 0, remove it from the list.

4. Return the size of the list.

Problem 3

Looks like a problem similar as word sequence which requires dynamic programing knowledge.

Expedia OA 90min

90mins，一共12道题，其中2道算法题，其他是 选择题，算法题很简单，选择题倒是有的没怎么见过。