{"id":"bb8d5d2d-b94c-4a56-af23-9523409000bc","name":"Number Of Employees Under Every Manager","description":"1. You are given number N and 2*N number of strings that contains mapping of the employee and his manager.\r\n2. An employee directly reports to only one manager. \r\n3. All managers are employees but the reverse is not true.\r\n4. An employee reporting to himself is the CEO of the company.\r\n5. You have to find the number of employees under each manager in the hierarchy not just their direct reports.","inputFormat":"A number N\r\nN number of lines, where each line contains 2 strings.","outputFormat":"Name of every employee and number of employees working under him.","constraints":"1 &lt;= N &lt;= 100","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n \nint main()\n{\n int n;\n cin>>n;\n \n //Write your code here\n \nreturn 0;\n \n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args){\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n \r\n //write your code here\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\nA C\r\nB C\r\nC F\r\nD E\r\nE F\r\nF F","sampleOutput":"A 0\r\nB 0\r\nC 2\r\nD 0\r\nE 1\r\nF 5\r\n","questionVideo":"https://www.youtube.com/embed/bit4Jn-ZoyQ?end=85","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"cdafb7ba-f3d5-46ad-9489-fc0c2490c274","name":"Number Of Employees Under Every Manager","slug":"number-of-employees-under-every-manager","type":1}],"next":{"id":"8e71ec97-99cf-4a13-b24c-dc660b610479","name":"Number of Employees Under Every Manager MCQ","type":0,"slug":"number-of-employees-under-every-manager-mcq"},"prev":null}}

Number Of Employees Under Every Manager

1. You are given number N and 2*N number of strings that contains mapping of the employee and his manager. 2. An employee directly reports to only one manager. 3. All managers are employees but the reverse is not true. 4. An employee reporting to himself is the CEO of the company. 5. You have to find the number of employees under each manager in the hierarchy not just their direct reports.

{"id":"bb8d5d2d-b94c-4a56-af23-9523409000bc","name":"Number Of Employees Under Every Manager","description":"1. You are given number N and 2*N number of strings that contains mapping of the employee and his manager.\r\n2. An employee directly reports to only one manager. \r\n3. All managers are employees but the reverse is not true.\r\n4. An employee reporting to himself is the CEO of the company.\r\n5. You have to find the number of employees under each manager in the hierarchy not just their direct reports.","inputFormat":"A number N\r\nN number of lines, where each line contains 2 strings.","outputFormat":"Name of every employee and number of employees working under him.","constraints":"1 &lt;= N &lt;= 100","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\n \nint main()\n{\n int n;\n cin>>n;\n \n //Write your code here\n \nreturn 0;\n \n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args){\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n \r\n //write your code here\r\n }\r\n\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"6\r\nA C\r\nB C\r\nC F\r\nD E\r\nE F\r\nF F","sampleOutput":"A 0\r\nB 0\r\nC 2\r\nD 0\r\nE 1\r\nF 5\r\n","questionVideo":"https://www.youtube.com/embed/bit4Jn-ZoyQ?end=85","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"cdafb7ba-f3d5-46ad-9489-fc0c2490c274","name":"Number Of Employees Under Every Manager","slug":"number-of-employees-under-every-manager","type":1}],"next":{"id":"8e71ec97-99cf-4a13-b24c-dc660b610479","name":"Number of Employees Under Every Manager MCQ","type":0,"slug":"number-of-employees-under-every-manager-mcq"},"prev":null}}
plane

Editor


Loading...

Number Of Employees Under Every Manager

easy

1. You are given number N and 2*N number of strings that contains mapping of the employee and his manager. 2. An employee directly reports to only one manager. 3. All managers are employees but the reverse is not true. 4. An employee reporting to himself is the CEO of the company. 5. You have to find the number of employees under each manager in the hierarchy not just their direct reports.

Constraints

1 <= N <= 100

Format

Input

A number N N number of lines, where each line contains 2 strings.

Output

Name of every employee and number of employees working under him.

Example

Sample Input

6 A C B C C F D E E F F F

Sample Output

A 0 B 0 C 2 D 0 E 1 F 5

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode