This is a verified interview question from Icpc-algoqueen. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Unique Frequencies - ICPC Algoqueen 2026" covers key patterns like Arrays.
"Hedy is securing a communication channel for a network of N torpedoes. Each torpedo operates on a frequency represented by an integer. The frequencies are given as an array A of N integers. To ensure secure transmission without interference, every torpedo must have a strictly unique frequency. Hedy can increase the frequency of any torpedo by 1 any number of times. Determine the minimum total number of increments required so that all frequencies become unique. Input Format The first line contains an integer T, the number of test cases. For each test case: The first line contains an integer N. The second line contains N space-separated integers: A1, A2, ..., AN. Output Format For each test case, output a single integer — the minimum total number of frequency increases required. Input 1 4 1 2 2 3 Output 2 Explanation Increase the second 2 to 4: 1 2 3 4 Total increments: (3-2) + (4-3) = 2"
Join thousands of developers practicing for Icpc-algoqueen.