Company: InMobi
Difficulty: medium
Employee Reportees Problem Description You have a company with N employees, with IDs from 1 to N. Employee 1 is the CEO and has no manager. Every other employee has exactly one manager. The task is to calculate and print the total number of reportees (both direct and indirect) for every employee, from ID 1 to N. Input: The first line is an integer N, the total number of employees. The next N-1 lines each contain two space-separated integers, n1 and n2, indicating that n2 is the manager of n1. Output: Print N space-separated integers. The first integer should be the total number of reportees for employee ID 1, the second for employee ID 2, and so on, up to employee ID N. Examples Example 1: Input: 5 2 1 3 2 4 1 5 3 Output: 4 2 1 0 0 Explanation: Employee 2's manager is 1. Employee 3's manager is 2. Employee 4's manager is 1. Employee 5's manager is 3. This structure can be represented as a tree with the CEO (ID 1) as the root: Employee 1 is the manager of 2 and 4. Employee 2 is the mana