12
返回列表 发新帖
楼主: crimsonfaith91
跳转到指定楼层
上一主题 下一主题
收起左侧

Google On-Campus 两轮

🔗
caffery24 2015-10-21 11:10:18 | 只看该作者
全局:
这个只需要打印current,那直接加入前打印了,然后就把queue中time不符合的输出,再把这秒的加进去???是不是我的想法太天真了。。。
回复

使用道具 举报

🔗
 楼主| crimsonfaith91 2015-10-21 23:05:29 | 只看该作者
全局:
caffery24, 你的想法应该是正确的。我当时把问题想得太复杂了。感觉问题一开始会简单点,然后难度会随着follow-ups增加。
回复

使用道具 举报

🔗
arjiang 2015-10-22 01:53:55 | 只看该作者
全局:
(2) what's the point of preserving many words if you only need print last one? How about just keep the latest word and it's time. If time older than X seconds, don't print it, otherwise print.
回复

使用道具 举报

🔗
 楼主| crimsonfaith91 2015-10-22 02:29:00 | 只看该作者
全局:
arjiang, the interviewer wants to print the last word, but also wants to know which words are within the indicated time duration.
回复

使用道具 举报

🔗
jobseeking 2015-10-22 15:16:40 | 只看该作者
全局:
不太理解第一题哦,如果输入是[1,3],[3,4],[5,6],如何标记3?是start还是end?

补充内容 (2015-10-22 15:17):
[1,3],[2,4],[2,5],[5,6]呢?
回复

使用道具 举报

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

使用道具 举报

🔗
jobseeking 2015-10-23 08:41:28 | 只看该作者
全局:
Thanks, BTW, I am going to post my code here:
  1. /**
  2. * Definition of Interval:
  3. * public classs Interval {
  4. *     int start, end;
  5. *     Interval(int start, int end) {
  6. *         this.start = start;
  7. *         this.end = end;
  8. *     }
  9. */

  10. class Solution {
  11.     /**
  12.      * @param intervals: An interval array
  13.      * @return: Count of airplanes are in the sky.
  14.      */
  15.     public int countOfAirplanes(List<Interval> airplanes) {
  16.         // write your code here
  17.         List<Point> list = new ArrayList<Point>();
  18.         for (Interval interval : airplanes) {
  19.             list.add(new Point(true, interval.start));
  20.             list.add(new Point(false, interval.end));
  21.         }
  22.         Collections.sort(list, new Comparator<Point> () {
  23.             public int compare(Point o1, Point o2) {
  24.                 if (o1.time == o2.time) {
  25.                     return o1.isStart ? 1 : -1;
  26.                 } else {
  27.                     return o1.time - o2.time;
  28.                 }
  29.             }
  30.         });
  31.         int counter = 0;
  32.         int max = 0;
  33.         for (Point p : list) {
  34.             if (p.isStart) {
  35.                 counter ++;
  36.             } else {
  37.                 counter --;
  38.             }
  39.             max = Math.max(max, counter);
  40.         }
  41.         return max;
  42.     }
  43.    
  44.     private static class Point {
  45.         private boolean isStart;
  46.         private int time;
  47.         public Point(boolean isStart, int time) {
  48.             this.time = time;
  49.             this.isStart = isStart;
  50.         }
  51.     }
  52. }
复制代码
回复

使用道具 举报

🔗
 楼主| crimsonfaith91 2015-10-23 08:44:01 | 只看该作者
全局:
job seeking, looks good to me. :)
回复

使用道具 举报

🔗
jobseeking 2015-10-23 09:05:47 | 只看该作者
全局:
楼主最后面的好吗?希望一切顺利
回复

使用道具 举报

🔗
 楼主| crimsonfaith91 2015-10-23 10:05:45 | 只看该作者
全局:
一般,哈哈。谢谢!
回复

使用道具 举报

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

本版积分规则

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