Skyscanner Interview Question for Software Engineers
- 0of 0 votes
You are given as input on stdin the number of employees in a company and their direct line management relations between each other. Each person in the company can directly line-manage maximum 2 other employees. The input from stdin has the following format:- twinmind February 02, 2015 in United Kingdom
1. on the first line, the number of employees
2. on the subsequent lines, the line management relations in the format «EmployeeM EmployeeN» - meaning EmployeeM manages EmployeeN (names are without spaces and spaces are used to separate the two names).
The input is correct (there are only direct management relations, no cycles).
For simplicity, the first line after the number of employees always contains the manager at the top of the hierarchy.
Write a program that reads the input file and then prints out the employees per level, in order of their importance (i.e. hierarchy):
Mark David Mat
| Report Duplicate | Flag | PURGE
Skyscanner Software Engineer Algorithm
Open Chat in New Window