← 返回 amazon 的题目列表Minimum Number of Pick Operations
类型:online_judge
You are given an array of integers locations, where locations[i] represents the location of the ith item. At each step, you can pick two items if they come from different locations (i.e., they have different values in locations). Once an item is picked, it is removed from the array, but the remaining items maintain their relative order. Return the minimum number of pick operations required to remove all the items from the array. Provide the implementation and test cases.
Example
Input
[1, 2, 2, 3]