Company: amazon_3march
Difficulty: medium
A financial services company has requested AWS for a private deployment of its cloud network. Considering the sensitive nature of the company’s business, AWS has also advised them to add a specific type of security system. Overall, there are n servers in the network where the security needs of the i th server are represented by the security[i], where each element represents the grade of security needed for a server. To ensure the highest possible protection, the AWS security team has recommended the following rule to be followed while designing the security system: All servers in a security group must have the same grade of security needs. The number of servers in any two security groups should not differ by more than 1. Given an integer array security, find the minimum number of security groups needed to ensure the protection of the network. Example Consider n = 6, security = [2, 3, 3, 3, 2, 1]. Then, the elements can be grouped as follows: Group 1: 2 devices of security grade 2 Group