This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Minimum Security Groups" covers key patterns like Arrays.
"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 'V' server are represented by the securityill, where each element represents the grade of security needed for a server. To ensure the highest protection possible, the AWS security team has recommended that the following rules be followed while designing the security system: All servers in a security group must have the same grade of security needs, and 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 levels needed to ensure the protection of the network. ### Example Consider n = 6, security = [2, 3, 3, 6, 2, 2]. Then, the elements can be grouped as follows: It requires 4 groups. ### Input - An integer array security representing the security needs of each server. ### Output - The minimum number of security groups needed. ### Constraints - 1 <= n <= 10^5 - 1 <= security(i) <= 10^6"
Join thousands of developers practicing for Amazon.