sandeepparekh9
BAN USER
- 1of 1 vote
AnswersThis is was asked in Amazon SDE online test from Hacker rank.
- sandeepparekh9 in Hong Kong
Initech is a company which has CEO Bill and a hierarchy of employees. Employees can have a list of other employees reporting to them, which can themselves have reports, and so on. An employee with at least one report is called a manager.
Please implement the closestCommonManager method to find the closest manager (i.e. farthest from the CEO) to two employees. You may assume that all employees eventually report up to the CEO.
Tree structure:
Bill -> Dom, Samir, Michael
Dom -> Bob, Peter, Porter
Peter -> Milton, Nina
Sample Data:
CEO Bill has 3 employees reporting to him: {Dom, Samir, Michael}
Dom has three reports { Peter, Bob, Porter}
Samir has no reports {}
Michael has no reports {}
Peter has 2 reports {Milton, Nina}
Bob has no reports {}
Porter has no reports {}
Milton has no reports {}
Nina has no reports {}
Sample calls:
closestCommonManager(Milton, Nina) = Peter
closestCommonManager(Nina, Porter) = Dom
closestCommonManager(Nina, Samir) = Bill
closestCommonManager(Peter, Nina) = Peter| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures
RepWhyable is an agile team of Software Specialists with vast experience across multiple languages.We will help you to define ...
RepDo you need dua for controlling husband? Contact Guru ji right now. He provides the best and simple dua to ...
RepDimaOxygen15, Computer Scientist at Headrun Technologies Pvt Ltd
Hi! all my sweets friends My name is Dimo Oxygen! Now I study in Victoria University of Wellington New Zealand ...
RepIsotherm is providing quality ceiling insulation and roofing insulation services to homes. We are one of the leading manufacturer company ...
Replovevashikaranmantrasolution, Data Engineer at ASAPInfosystemsPvtLtd
Are you searching the mantra for your lost love boyfriend? BabaJi will guide you with simple and effective mantra to ...
RepTop Tiers provides latest english premier league articles and news to keep you up to date. Visit our website today ...
Repour goal is to help individuals companies and organizations of all kinds to communicate with their clients customer and employees ...
RepDiscover the best preschool for kids Charlotte. Visit Pal-A-Roo’se, one of the trusted early childhood & child development center in ...
Repriverajenny935, i love my shop piano at xyz
Hello Everyone,My Name is Jenny Rivera .I have been a piano instructor for more than 25 years! I earned ...
RepGet boyfriend back by vashikaran mantra. Astrologer Guru ji is the best black magic and vashikaran specialist. He offers instant ...
RepVirginialdelmonte, Animator at lostlovebackvashikaran
Have you lost your husband love? And you want to control your husband mind with vashikaran mantra. Guru ji is ...
c# solution:
- sandeepparekh9 January 20, 2016