Company: Amazon HackOn
Difficulty: easy
An Amazon distribution specialist needs to process n packages that arrive from different distribution centers. The packages sit in a queue, and the centre of the i -th package is given by centers[i] . The specialist may perform one operation at a time. Each operation is one of the following: If the queue holds two or more packages, choose two packages x and y from the queue whose distribution centres differ (that is, centers[x] != centers[y] ) and process both of them. If the queue holds one or more packages, choose a single package x from the queue and process it. Note: after a package is processed it is removed from the queue, and the packages that are still unprocessed close up, keeping their relative order unchanged. Given n packages and the array centers , find the minimum number of operations the specialist has to perform in order to process every package. Input Format The first line contains a single integer n , the number of packages. Each of the next n lines contains a single