回复: 12
跳转到指定楼层
上一主题 下一主题
收起左侧

Google phone

全局:

2018(1-3月) 码农类General 硕士 全职@google - 猎头 - 技术电面  | | Pass | 在职跳槽

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

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

x
Had Google phone last week. Onsite next week.
1. In an array with positive, negative and zero floats, find continuous subarray that has maximum product, output the start and end index of this subarray.
2. Design a da
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
of keyword "final", what's the difference between "final" and "static", etc.


上一篇:为了我们全部 oa
下一篇:Airbnb 18 summer intern SDE
推荐
 楼主| RC-ACK 2018-2-19 05:55:21 | 只看该作者
全局:
jasonyang04 发表于 2018-2-19 03:43
How did you implement adding interval? O(N) time? Do we need to merge the overlapped intervals like  ...

I kept all intervals sorted so insertion could be done in O(logn) time but I don't think I implemented it correctly - coded an O(n) solution, tried to optimize to O(logn) but may have made some mistakes.

With all intervals sorted, search can be done in O(logn) time for sure.

They let me pass anyway so I don't think bar is too high for a phone screen.
回复

使用道具 举报

推荐
jasonyang04 2018-2-19 12:14:12 | 只看该作者
全局:
RC-ACK 发表于 2018-2-19 05:55
I kept all intervals sorted so insertion could be done in O(logn) time but I don't think I impleme ...

My consideration is that if you use List<> to store intervals, there is no way to be O(logN) because insertion for List<> is O(N). Even if you use binary search to find the position for an interval, insertion will still cost O(N).
回复

使用道具 举报

推荐
wenyitiger 2018-5-8 14:12:10 | 只看该作者
全局:
我觉得O(n) 可以接受 毕竟worst case  interval 已经排序了 你从小加到大 也是O(n)  当然可以写个best log(n) 的
真.log(n) 不是不可能 而是得有一个balanced BST 楼上说的interval tree的前提也是balanced BST 但是电面总不至于写红黑树吧哈哈lol
回复

使用道具 举报

🔗
anywho 2018-2-19 01:43:37 | 只看该作者
全局:
第二道是用segment tree来做么
回复

使用道具 举报

🔗
jasonyang04 2018-2-19 03:43:56 | 只看该作者
全局:
How did you implement adding interval? O(N) time? Do we need to merge the overlapped intervals like [1,2] and [1,5] ?
回复

使用道具 举报

🔗
 楼主| RC-ACK 2018-2-19 05:52:42 | 只看该作者
全局:
anywho 发表于 2018-2-19 01:43
第二道是用segment tree来做么

Segment tree does not allow insertion. Interval tree is more accurate.
回复

使用道具 举报

🔗
devilnut 2018-2-19 10:07:02 | 只看该作者
全局:
RC-ACK 发表于 2018-2-19 05:55
I kept all intervals sorted so insertion could be done in O(logn) time but I don't think I impleme ...

You didn’t merge intervals?
回复

使用道具 举报

🔗
Kwang100 2018-2-21 08:54:46 | 只看该作者
全局:
jasonyang04 发表于 2018-2-19 12:14
My consideration is that if you use List to store intervals, there is no way to be O(logN) because ...

哈哈,大家怎么都用英语了..
我感觉和你差不多啊。这题应该就是插入O(n),search O(logn)吧?有什么advanced的做法吗?
回复

使用道具 举报

全局:
Kwang100 发表于 2018-2-21 08:54
哈哈,大家怎么都用英语了..
我感觉和你差不多啊。这题应该就是插入O(n),search O(logn)吧?有什么a ...

在 ArrayList里面放 Interval如果每次加完新的 Interval之后要进行 mergeInterval的工作的话,也是很麻烦...而且两次二分法也是很烦...
回复

使用道具 举报

全局:
感谢楼主分享,希望楼主 onsite顺利,offer多多
回复

使用道具 举报

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

本版积分规则

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