注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Zoom 店面,
题目相对比较长, 需要一定时间理清逻辑。 不过理清之后还是很简单的。 提前20 分钟结束了。
/*
Best friend feature:
We want to implement a feature to allow zoom users to know who are their best friends on zoom. Your best zoom friends are defined as
users who spends the most time in meetings with you. Given the map, write a function to rank the top friends.
Note: If 2 users are tied for time spent in meeting, resolve the tie by number of meetings spent, if that is still tied,
output the tied users in any order
input: userId->meetingId->time intervals
List<String> bestFriends(Map<String, Map<String, List<List<Long>>>> timestamps, String userId);
example:
userId: user1
user1-> [meeting1]-> [[1,3],[5,7]]
[meeting2]-> [[7,10]]
[meeting3]-> [[3,5]]
[meeting4]-> [[10,12]]
user2-> [meeting1]-> [[1,3]]
user3-> [meeting1]-> [[1,2]]
[meeting2]-> [[9,10]]
user4-> [meeting2]-> [[7,11],[13,15]]
output:
user4 (3 hours), user3 (2 hours, 2 meetings), user2 (2 hours, 1 meeting)
*/
|