注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
第一题:
Amazon Music is working on a new feature to pair songs together to play while on the bus.
The goal of this feature is to select two songs from a list that will end exactly 30 seconds
before the listener reaches their stop. You are tasked with writing the method that selects
the songs from a list. Each song is assigned a unique ID, numbered from O to N-1.
Assumptions:
1. You will pick exactly two songs
2. You cannot pick the same song twice.
3. If you have multiple pairs with the same total time, select thend exactly 30 seconds before the bus arrives at their
stop.
If two songs have the same duration, select the option with the lowest index.
two sum, 有多个答案选择包含最长duration歌曲的答案。
第二题:
第二题排序两个数组,用二分搜索在第二个数组中搜索目标值和第一个数组中的差。但是有几个case没过debug 没debug出来。
求米!
|