楼主: 匿名
跳转到指定楼层
上一主题 下一主题
收起左侧

Facebook Additional Phone Interview

🔗
1guangnian 2014-11-18 09:02:37 | 只看该作者
全局:
感觉把start time和end time拆开来,排个序就好了吧。。start time权值为1,end time权值-1
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-VVM0T  2014-11-18 09:04:51
1guangnian 发表于 2014-11-18 09:02
感觉把start time和end time拆开来,排个序就好了吧。。start time权值为1,end time权值-1

This is my final answer...but lz did not finish....crycrycry
回复

使用道具 举报

🔗
pazzaintermilan 2014-11-18 09:07:02 | 只看该作者
全局:
为什么lz的实习面都这么难。。。其他全职的onsite都很多原题的感觉。。。
回复

使用道具 举报

🔗
1guangnian 2014-11-18 09:09:23 | 只看该作者
全局:
论坛匿名用户 发表于 2014-11-18 09:04
This is my final answer...but lz did not finish....crycrycry

pat pat...
回复

使用道具 举报

🔗
yvetterowe 2014-11-18 09:10:40 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-VVM0T  2014-11-18 09:14:35
pazzaintermilan 发表于 2014-11-18 09:07
为什么lz的实习面都这么难。。。其他全职的onsite都很多原题的感觉。。。

fate               
回复

使用道具 举报

🔗
北美农民 2014-11-18 10:25:46 | 只看该作者
全局:
不用急, intern 的 bar并不高。
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-VVM0T  2014-11-18 10:29:42
北美农民 发表于 2014-11-18 10:25
不用急, intern 的 bar并不高。

请烧纸                  
回复

使用道具 举报

🔗
中庸人90 2014-11-18 14:09:19 | 只看该作者
全局:
求问大神,如何用segement tree做,插入的时候当某个区间往下递归的时候跨了几个区间,怎么标记以及查询的时候怎么回收统计的值?或者别的思路??
回复

使用道具 举报

🔗
sweeney1130 2014-11-19 03:53:11 | 只看该作者
全局:
先排序,然后再扫一遍,感觉代码写的很冗余。

  1. struct CompareStart
  2. {
  3.     bool operator() (const Employee &a, const Employee &b){
  4.         return a.startTime < b.startTime;
  5.     }
  6. };

  7. struct CompareEnd
  8. {
  9.     bool operator() (const Employee &a, const Employee &b){
  10.         return a.endTime < b.endTime;
  11.     }
  12. };

  13. void PrintEmployeeWorkTime(vector<Employee> start_staff){
  14.     int num_em = start_staff.size();
  15.     if (num_em == 0) return;
  16.     vector<Employee> end_staff(start_staff);
  17.     sort(start_staff.begin(), start_staff.end(), CompareStart());
  18.     sort(end_staff.begin(), end_staff.end(), CompareEnd());
  19.     int idx_st = 1, idx_end = 0, count = 1, timestamp = start_staff[0].startTime;
  20.     int cur_st, cur_end;
  21.     while (start_staff[0].startTime == start_staff[idx_st].startTime) {idx_st++;count++;}

  22.     while (idx_st < num_em || idx_end < num_em){
  23.         cur_st = start_staff[idx_st].startTime;
  24.         cur_end = end_staff[idx_end].endTime;
  25.         cout << timestamp << "-" << min(cur_st,cur_end) << ":\t" << count << endl;
  26.         if (cur_st <= cur_end){
  27.             count++;
  28.             idx_st++;
  29.             while (idx_st < num_em && cur_st == start_staff[idx_st].startTime) {idx_st++;count++;}
  30.             timestamp = cur_st;
  31.         }
  32.         if (cur_st >= cur_end){
  33.             count--;
  34.             idx_end++;
  35.             while (idx_end < num_em && cur_end == end_staff[idx_end].endTime) {idx_end++;count--;}
  36.             timestamp = cur_end;
  37.         }
  38.     }
  39. }
复制代码
回复

使用道具 举报

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

本版积分规则

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