Min Operation
The manager of an Amazon warehouse needs to ship n products from different locations, the location of the ith product is represented by an array locations[i]. The manager is allowed to perform one operation at a time. Each operation is described below:
Note: After shipping a product it gets removed from the inventory, and the rest of the products which are currently not shipped come together keeping the order the same as before.
Given n products and an array locations, find the minimum number of operations that the manager has to perform to ship all of the products.
Complete the function minOperation in the editor.
minOperation has the following parameter(s):
int locations[n]: the location of each product.
Returns
int: the minimum number of operations that the manager has to perform to ship all of the products.
1Example 1

2Example 2

Constraints
Limits and guarantees your solution can rely on.
1 <= m <= 10^51 <= locations[i] <= 10^9