查看: 1311| 回复: 1
跳转到指定楼层
上一主题 下一主题
收起左侧

[学Java/C#] 请教一道amazon面试题 video watched by friends

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

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
}

评分

参与人数 2大米 +3 收起 理由
14417335 + 2
lemoncorn1123 + 1 赞一个

查看全部评分


上一篇:问一道狗家高频,Max Product Of Binary Tree
下一篇:76 为什么我的滑 动窗口 最后一个 case就是通不过
🔗
GYing 2020-2-27 13:10:35 | 只看该作者
本楼:
全局:
感谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表