📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

Doordash 店面

全局:

2019(10-12月) 码农类General 硕士 全职@doordash - 猎头 - 技术电面  | | Other | 在职跳槽

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

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

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]
代码
您好!
本帖隐藏的内容需要积分高于 200 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 200 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies




评分

参与人数 4大米 +32 收起 理由
rainly + 2 很有用的信息!
willwillzhang + 3 给你点个赞!
Celine00 + 2 很有用的信息!
匿名用户-VZXIM + 25

查看全部评分


上一篇:Wayfair Offer & Interview Tips & Gossips
下一篇:卖力面试
🔗
ge就服你 2019-11-11 10:03:36 | 只看该作者
全局:
请问lz电面几轮呀,有没有ood编程
回复

使用道具 举报

🔗
 楼主| ZhengzhengWVDE 2019-11-12 02:38:43 | 只看该作者
全局:
ge就服你 发表于 2019-11-11 10:03
请问lz电面几轮呀,有没有ood编程

就一轮,没有ood
回复

使用道具 举报

🔗
R35GTR 2019-12-12 11:28:27 | 只看该作者
全局:
請問 LZ 有昂賽嗎?可以分享一下嗎?謝謝
回复

使用道具 举报

🔗
willwillzhang 2020-7-22 11:41:23 | 只看该作者
全局:
可以写的更简单:
  1. public class MeetingSchedule {

  2.     public static void main(String[] args) {

  3.         int[][] input = {{3, 20}, {-2, 0}, {0, 2}, {16, 17}, {19, 23}, {30, 40}, {27, 33}};

  4.         for (int[] i : minAvailableDuration(input, -5, 27, 2))
  5.             System.out.println(Arrays.toString(i));
  6.     }

  7.     public static List<int[]> minAvailableDuration(int[][] slots, int startTime, int endTime, int duration) {
  8.         Arrays.sort(slots, (a, b) -> a[0] - b[0]);
  9.         List<int[]> res = new ArrayList<>();

  10.         for (int i = 0; i < slots.length; i++) {
  11.             if (slots[i][0] >= startTime && slots[i][0] <= endTime) {
  12.                 if (i == 0)
  13.                     res.add(new int[]{startTime, slots[i][0]});
  14.                 else if (slots[i][0] - slots[i - 1][1] >= duration + 1) {
  15.                     res.add(new int[]{slots[i - 1][1], slots[i][0]});
  16.                 }
  17.             }

  18.         }

  19.         return res;
  20.     }
  21. }
复制代码

[i][i][/i][/i]
回复

使用道具 举报

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

本版积分规则

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