#C1880. Count Departments with Duplicate Salaries
Count Departments with Duplicate Salaries
Count Departments with Duplicate Salaries
You are given several test cases. For each test case, you are provided with employee records where each record contains an ID, Name, Department, and Salary. Your task is to count the number of departments that have at least one salary which occurs more than once.
Formally, for each department, if there exists a salary \(s\) such that its frequency in that department is at least 2 (i.e. \(count(s) \ge 2\)), then the department qualifies; count it once. Output the count of such departments for each test case.
Note: The input is read from standard input and the output should be written to standard output.
inputFormat
The first line contains an integer \(T\) (number of test cases). For each test case, the first line contains an integer \(N\) (number of employee records). The next \(N\) lines each contain an employee record in the following format:
ID Name Department Salary
Fields are separated by spaces. You can assume that ID and Salary are integers, while Name and Department are strings without spaces.
outputFormat
For each test case, output a single integer on a new line that denotes the number of departments that have at least one duplicate salary (i.e., a salary that appears at least twice).
## sample1
5
101 John HR 50000
102 Jane IT 60000
103 Tom HR 50000
104 Mike Sales 70000
105 Amy IT 60000
2
</p>