注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
看到面经里有一道这个题 round 3 tech: https://www.1point3acres.com/bbs ... p;extra=#pid9274460
想问几个问题 是 关于 round 3 那个tech 问题, 大家可以帮忙看看吗,谢谢。
1. Person 跟 Video 这两个class 面试有给出定义吗?mostWatchedVideosFromFriends 我是想用hashset 去排除本人看过的video,用hashmap 统计频率再进行bucket sort。
2. followup 那个问题想的是先BFS 求出所有direct 和 indirect friends 。然后分别调用getWatchedVideos(Person person), 把所有的List<Video> 用hashmap 统计频率再进行bucket sort。
还有更优的解法吗?
我是准备用Video作为key,这里需不需要自定义hashcode 跟 equal method 啊?谢谢。
HashSet<Video>
HashMap<Video, Integer>
补充内容 (2019-12-22 13:19):
Tech: Given 2 helper methods,
public List<Video> getWatchedVideos(Person person) {
// Return a list of Video objects that has been watched by the given person
}
public List<Person> getFriends(Person person) {
// Return a list of Person objects who are the friends of the given person
}
Write a method to return a list of ALL videos that have been watched by a given person’s immediate friends,
* The videos in the returned list should be sorted by the frequencies that it was watched
* The videos in the returned list contain only videos that hasn’t been watched by the given person
The method signature:
public List<Video> mostWatchedVideosFromFriends(Person person) {
//
}
Follow up: How to implement a method to return a list of ALL videos that have been watched by a given person’s friends, friends of friends, friends of friends of friends, etc. The level of friends of friends is an integer larger than 0, e.g.,
public List<Video> mostWatchedVideosFromFriends(Person person, int friendsOfFriendsLevel) {
// If friendsOfFriendsLevel = 1, the follow up question becomes the original question
} |