Company: Amazon HackOn
Difficulty: medium
An Amazon distribution specialist needs to process n packages from different distribution centers, the center of the i th package is represented by an array centers[i] . The specialist is allowed to perform one operation at a time. Each operation is described below: If the queue has two or more packages, the specialist can choose two packages x and y from the queue if they are from different distribution centers. i.e. centers[x] != centers[y] and process both of them. If the queue has one or more packages, the specialist can choose one package x from the queue and process it. Note: After processing a package it gets removed from the queue, and the rest of the packages which are currently not processed come together keeping the order the same as before. Given n packages and an array centers , find the minimum number of operations that the specialist has to perform to process all of the packages. Example: Given n =5 and centers =[3, 7, 5, 6, 6]. Operation x y centers 1. 1 5 [7, 5, 6] 2.