面试题

来源:互联网 发布:linux vi如何到指定行 编辑:程序博客网 时间:2024/06/07 05:25

今天去面试,给了我一套面试题,有4道题,回答其中一道就可以,我一看当场就懵bi了,题目是这样的:

一、Mala-Offline is a company which has CEO Bill and a heerarchy of employees.Employees can have a list of toher 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 closesCommonManager method to find this closest manager(i.e.farthest from the CEO) to two employees. You may assume that all employees eventually report up to the CEO.

Simple data:

CEO Bill has 3 employees reporting to him:{DOM,SAMIR,MICHAEL}

DOM has three reports{PETER,SOS,PORTER}

SAMIR has no reports{}

MICMAEL has no reports{}

PETER has 2 reports{MILTON,NINA}

SOS has no reports{}

PORTER has no reports{}


Simple calls:

closestCommonManager(MILTOM,NINA) = PETER

closestCommonManager(NINA,PORTER) = DOM

closestCommonManager(NINA,SAMIR) = BILL

closestCommonManager(PETER,NINA) = PETER


使用C++或java语言实现(任选一种):




先上传第一道题目,其他的以后再说,表示手打英文真的好累!

答案正在研究,以后会解答,另外,有哪位大神有思路可以下方留言哦~~



1 0
原创粉丝点击