注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 ZhengzhengWVDE 于 2019-11-6 08:57 编辑
上来自我介绍,就开始做题。题目和代码都贴上来好了,跟我上周面的uber基本一样,但是简单很多,没有merge interval的过程。。。希望对大家有帮助。。。
求大米
[hide==188]
/*
Google Calendar, Outlook, iCal has been banned from your company! So an intrepid engineer has decided to roll their own implementation. Unfortunately one major missing feature is the ability to find out what time slots are free for a particular individual.
Given a list of time blocks where a particular person is already booked/busy, a start and end time to search between, a minimum duration to search for, find all the blocks of time that a person is free for a potential meeting that will last the aforementioned duration.
Given: start_time, end_time, duration, meetings_list -> suggested_meeting_times
Let's assume we abstract the representation of times as simple integers, so a valid time is any valid integer supported by your environment. Here is an example input:
meetings_list: [3,20], [-2, 0], [0,2], [16,17], [19,23], [30,40], [27, 33]
start_time: -5
end_time: 27
min_duration: 2
expected answer:
free_time: [-5, -2], [23,27]
Feel free to represent the meetings however you would like, i.e. List of Lists, Lists of Objects etc.
*/
[/hide]
代码
|