回复: 23
跳转到指定楼层
上一主题 下一主题
收起左侧

Uber 面经 (2015年8月)

全局:

2015(7-9月) 码农类General 硕士 全职@uber - 内推 - 技术电面  | | Fail | 应届毕业生

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

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

x
有同学在Uber实习,请其Mentor帮忙内推,拿到面试。两轮电面之后被拒。发个面经攒攒人品。安排时间非常效率,确实是正在快速扩张的团队。周一联络然后第一轮安排在同一周的周四,然后周五联系第二轮,安排在下一周的周一,然后第二轮后两天发拒信。
面试在codepad上进行,所以可以现场执行,要
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
的中位数。
先给brute force,对所有数据排序然后找中位数。
之后改进版YY了一个基于bucket的方法,算是在精确度和时空复杂度之间的trade off,不过面试官不是很满意……




评分

参与人数 1大米 +40 收起 理由
whdawn + 40

查看全部评分


上一篇:Coursera phone interview
下一篇:Epic 完整面经
全局:
First One.
  1. import java.util.ArrayList;
  2. import java.util.List;

  3. class Solution {
  4.     public static void main(String[] args) {
  5.         String words = "This is good meal. I love it. I want to have it everyday.";
  6.         Answer ans = new Answer();
  7.         if (ans.process(words, 10) == -1) {
  8.             System.out.println("Error");
  9.         } else {
  10.             ans.print();
  11.         }
  12.     }
  13. }

  14. class Answer {
  15.     List<String> lists;
  16.     int limit;
  17.     int remaining;
  18.     StringBuilder builder;

  19.     public void print() {
  20.         int size = lists.size();
  21.         int cnt = 1;
  22.         for (String line : lists) {
  23.             System.out.println(line + " (" + cnt + "/" + size + ")");
  24.             cnt++;
  25.         }
  26.     }

  27.     public int process(String words, int limit) {
  28.         this.lists = new ArrayList<String>();
  29.         this.limit = limit;
  30.         this.remaining = limit;
  31.         this.builder = new StringBuilder();

  32.         int fast = 0;
  33.         int slow = 0;
  34.         // or words.split(" +");
  35.         while (fast < words.length()) {
  36.             while (fast < words.length() && Character.isSpaceChar(words.charAt(fast))) {
  37.                 fast++;
  38.                 slow++;
  39.             }
  40.             while (fast < words.length() && !Character.isSpaceChar(words.charAt(fast))) {
  41.                 fast++;
  42.             }
  43.             if (insert(words.substring(slow, fast)) == -1) return -1;
  44.             slow = fast;
  45.         }

  46.         if (builder.length() > 0) {
  47.             lists.add(builder.toString());
  48.         }

  49.         return 0;
  50.     }

  51.     public int insert(String word) {
  52.         if (builder.length() == 0) {
  53.             if (word.length() > limit) {
  54.                 return -1;
  55.             } else {
  56.                 builder.append(word);
  57.                 remaining -= word.length();
  58.             }
  59.         } else if (1 + word.length() <= remaining) {
  60.             builder.append(" ").append(word);
  61.             remaining -= 1+ word.length();
  62.         } else {
  63.             lists.add(builder.toString());
  64.             builder = new StringBuilder();
  65.             remaining = limit;
  66.             return insert(word);
  67.         }
  68.         return 0;
  69.     }


  70. }
复制代码
回复

使用道具 举报

全局:
第二题,感觉就是把每个list都sort一下,然后就是merge N sorted list问题,用一个counter记录找到median就可以了。
那个Log(N)的median of two sorted array太复杂了,而且你这个又是N个list,有限时间内,应该很难Log(N)写出来。
  1. import java.util.*;

  2. class Solution {
  3.     public static void main(String[] args) {
  4.         List<List<Integer>> lists = new ArrayList<List<Integer>>();
  5.         lists.add(Arrays.asList(9, 6, 3));
  6.         lists.add(Arrays.asList(8, 5, 2));
  7.         lists.add(Arrays.asList(7, 4, 1));

  8.         Answer ans = new Answer();
  9.         int ret = ans.process(lists);
  10.         System.out.println(ret);
  11.     }
  12. }

  13. class Answer {
  14.     List<List<Integer>> lists;
  15.     int count;
  16.     PriorityQueue<Item> heap;

  17.     public int process(List<List<Integer>> lists) {
  18.         this.lists = lists;
  19.         this.count = 0;
  20.         heap = new PriorityQueue<Item>(100, new Comparator<Item>() {
  21.             @Override
  22.             public int compare(Item o1, Item o2) {
  23.                 return ((Integer) o1.val).compareTo(o2.val);
  24.             }
  25.         });

  26.         for (int i = 0; i < lists.size(); i++) {
  27.             List<Integer> list = lists.get(i);
  28.             count += list.size();
  29.             Collections.sort(list);
  30.             if (!list.isEmpty()) {
  31.                 heap.add(new Item(list.get(0), i, 0));
  32.             }
  33.         }

  34.         int idx = 0;
  35.         while (!heap.isEmpty()) {
  36.             Item item = heap.poll();
  37.             if (idx == count / 2) {
  38.                 return item.val;
  39.             } else {
  40.                 idx++;
  41.             }
  42.             if (item.col < lists.get(item.row).size() - 1) {
  43.                 heap.add(new Item(lists.get(item.row).get(item.col + 1), item.row, item.col + 1));
  44.             }
  45.         }

  46.         return 0;
  47.     }

  48. }

  49. class Item {
  50.     int val;
  51.     int row;
  52.     int col;

  53.     public Item(int val, int row, int col) {
  54.         this.val = val;
  55.         this.row = row;
  56.         this.col = col;
  57.     }
  58. }
复制代码
回复

使用道具 举报

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

使用道具 举报

🔗
flyaway25 2015-8-20 22:16:11 | 只看该作者
全局:
求问lz你面的是哪个team?
回复

使用道具 举报

🔗
 楼主| clockwise9 2015-8-20 22:18:11 | 只看该作者
全局:
flyaway25 发表于 2015-8-20 22:16
求问lz你面的是哪个team?

听说new grad是先general地面试然后再match team。
回复

使用道具 举报

🔗
flyaway25 2015-8-20 22:19:33 | 只看该作者
全局:
clockwise9 发表于 2015-8-20 22:18
听说new grad是先general地面试然后再match team。

当时填那个link里面不是有几个team么,我问hr,hr说尽量根据那个interest来安排你面试的人
回复

使用道具 举报

🔗
 楼主| clockwise9 2015-8-20 22:57:43 | 只看该作者
全局:
flyaway25 发表于 2015-8-20 22:19
当时填那个link里面不是有几个team么,我问hr,hr说尽量根据那个interest来安排你面试的人

哦想起来了,我填的应该是Backend和RealTimeSystem
回复

使用道具 举报

🔗
jiebour 2015-8-20 23:42:22 | 只看该作者
全局:
楼主,2/3这三个字符算吗?

补充内容 (2015-8-21 07:36):
还有,楼主求个靠谱内推。。。。谢谢!
回复

使用道具 举报

🔗
一日一ad 2015-8-21 05:34:46 | 只看该作者
全局:
请问lz已经毕业了嘛?
回复

使用道具 举报

🔗
 楼主| clockwise9 2015-8-21 09:26:45 | 只看该作者
全局:
jiebour 发表于 2015-8-20 23:42
楼主,2/3这三个字符算吗?

补充内容 (2015-8-21 07:36):

当然是算在里面的,所以才tricky
回复

使用道具 举报

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

本版积分规则

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