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

请教Uber onsite follow up interview

🔗
 楼主| rebe90 2015-11-26 01:42:15 | 只看该作者
全局:
温家小猫 发表于 2015-11-25 09:41
楼主加油啊,我周一面的,目前还没有消息。。。

祝你好运呀!可能这周有holiday会通知的慢一些?
回复

使用道具 举报

🔗
 楼主| rebe90 2015-12-3 07:21:32 | 只看该作者
全局:
follow up interview: tech interview, design rate limiter,C++ chrono库里的函数用的不熟,边查边写的,不知道面试官会不会介意T.T 求RP...
回复

使用道具 举报

🔗
温家小猫 2015-12-4 00:42:58 | 只看该作者
全局:
rebe90 发表于 2015-11-26 01:42
祝你好运呀!可能这周有holiday会通知的慢一些?

谢谢楼主,已收到offer,也祝楼主顺利拿到!
回复

使用道具 举报

🔗
bobzhang2004 2015-12-4 12:32:23 | 只看该作者
全局:
写了下第三题java版,感觉它们加系统设计真多啊
  1. public class GroupContacts {

  2.         static class Contact {
  3.                 String name;
  4.                 List<String> emails;
  5.                 public Contact(String name, List<String> emails) {
  6.                         this.name = name;
  7.                         this.emails = emails;
  8.                 }
  9.         }

  10.         static class UnionFind {
  11.                 HashMap<Integer, Integer> father = new HashMap<Integer, Integer>();

  12.                 UnionFind(int n) {
  13.                         for (int i = 0; i < n; i++) {
  14.                                 father.put(i, i);
  15.                         }
  16.                 }

  17.                 int compressed_find(int x) {
  18.                         int parent = father.get(x);
  19.                         while (parent != father.get(parent)) {
  20.                                 parent = father.get(parent);
  21.                         }
  22.                         int tmp = -1;
  23.                         int fa = father.get(x);
  24.                         while (fa != father.get(fa)) {
  25.                                 tmp = father.get(fa);
  26.                                 father.put(fa, parent);
  27.                                 fa = tmp;
  28.                         }

  29.                         return parent;
  30.                 }

  31.                 int find(int id) {
  32.                         while (id != father.get(id)) {
  33.                                 id = father.get(id);
  34.                         }

  35.                         return id;
  36.                 }

  37.                 void union(int x, int y) {
  38.                         int fa_x = compressed_find(x);
  39.                         int fa_y = compressed_find(y);
  40.                         father.put(fa_x, fa_y);
  41.                 }
  42.         }

  43.         public static List<List<Contact>> groupContacts(Contact[] input) {
  44.                 Map<String, List<Integer>> emailRecord = new HashMap<String, List<Integer>>();

  45.                 int n = input.length;
  46.                 for (int k = 0; k < input.length; k++) {
  47.                         for (String email : input[k].emails) {
  48.                                 if (emailRecord.containsKey(email)) {
  49.                                         emailRecord.get(email).add(k);
  50.                                 } else {
  51.                                         List<Integer> list = new ArrayList<Integer>();
  52.                                         list.add(k);
  53.                                         emailRecord.put(email, list);
  54.                                 }
  55.                         }
  56.                 }
  57.                 UnionFind uf = new UnionFind(n);
  58.                 for (List<Integer> p : emailRecord.values()) {
  59.                         for (int i = 0; i < p.size() - 1; i++) {
  60.                                 uf.union(p.get(i), p.get(i + 1));
  61.                         }
  62.                 }
  63.                 Map<Integer, List<Integer>> groups = new HashMap<Integer, List<Integer>>();
  64.                 for (int i = 0; i < n; i++) {
  65.                         int parent = uf.find(i);
  66.                         if (groups.containsKey(parent)) {
  67.                                 groups.get(parent).add(i);
  68.                         } else {
  69.                                 List<Integer> list = new ArrayList<Integer>();
  70.                                 list.add(i);
  71.                                 groups.put(parent, list);
  72.                         }
  73.                 }

  74.                 List<List<Contact>> ret = new ArrayList<List<Contact>>();
  75.                 for (List<Integer> p : groups.values()) {
  76.                         List<Contact> vs = new ArrayList<Contact>();
  77.                         for (int c : p) {
  78.                                 vs.add(input[c]);
  79.                         }
  80.                         ret.add(vs);
  81.                 }
  82.                 return ret;
  83.         }
  84.        
  85.         public static void main(String[] args) {
  86.                 Contact c1 = new Contact("John", Arrays.asList("john@gmail.com"));
  87.                 Contact c2 = new Contact("Mary", Arrays.asList("mary@gmail.com"));
  88.                 Contact c3 = new Contact("John", Arrays.asList("john@yahoo.com"));
  89.                 Contact c4 = new Contact("John", Arrays.asList("john@gmail.com", "john@yahoo.com", "john@hotmail.com"));
  90.                 Contact c5 = new Contact("Bob", Arrays.asList("bob@gmail.com"));
  91.                 Contact[] input = {c1, c2, c3, c4, c5};
  92.                 List<List<Contact>> res = groupContacts(input);
  93.                 for (List<Contact> list : res) {
  94.                         for (Contact i : list) {
  95.                                 System.out.print(i.name + ":  ");
  96.                                 for (String email : i.emails) {
  97.                                         System.out.print(email + " ");
  98.                                 }
  99.                         }
  100.                         System.out.println();
  101.                 }
  102.         }
  103. }
复制代码
回复

使用道具 举报

🔗
bobzhang2004 2016-1-12 04:15:05 | 只看该作者
全局:
楼主可以具体说说subscription 和tilt maze是什么,楼主怎么做的吗?
回复

使用道具 举报

🔗
baozijun 2016-1-17 15:23:15 | 只看该作者
全局:
并查集写的很牛!这是一个视频,分享给大家,讲得也很好。
https://www.youtube.com/watch?v=hqvV2ui29fQ

Tilt maze你怎么想的?用什么数据结构来表示maze? 应该还是DFS
https://www.mathsisfun.com/games/tilt-maze.html
回复

使用道具 举报

🔗
jygan 2016-1-19 01:06:13 | 只看该作者
全局:
第一题excel是设计题还是leetcode上的那两道之一?
回复

使用道具 举报

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

本版积分规则

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