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

uber 电面, 已跪

全局:

2016(1-3月) 码农类General 博士 全职@uber - 内推 - 技术电面  | | Fail | 应届毕业生

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

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

x

电面连续被放两次鸽子,第三次跪了。。。

面的Infrastructure组

聊了下project
然后问会不会数据库, Nosql (不会)
用过clo
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
, c的概率 3/6

follow up,怎么确定结果是不是对的




评分

参与人数 1大米 +50 收起 理由
tommylin + 50

查看全部评分


上一篇:Uber面试分享
下一篇:Palantir Intern 2016 Summer OA
🔗
rayord 2015-11-8 06:42:59 | 只看该作者
全局:
解决思路应该就是随机数吧, 写一个累积数组,然后随机数(1~6),如果是[1,1],返回a,如果是[2,3],返回b,如果是[4,6],返回c. follow up: 运行10000次,统计输出结果,计算下概率看符合不应该就可以了。Uber好像都是算法+测试用例。
回复

使用道具 举报

🔗
 楼主| caigaa 2015-11-8 06:46:17 | 只看该作者
全局:
rayord 发表于 2015-11-8 06:42
解决思路应该就是随机数吧, 写一个累积数组,然后随机数(1~6),如果是[1,1],返回a,如果是[2,3],返回b ...

我就是这个思路做的。中间编译程序发现了两个typo。。。汗,太大意了
回复

使用道具 举报

🔗
likenisha 2015-11-29 01:10:15 | 只看该作者
全局:
啥都不会真的是蛋疼,LZ后来如哪儿了
回复

使用道具 举报

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

使用道具 举报

🔗
bobzhang2004 2016-2-7 11:39:34 | 只看该作者
全局:
写了下code,
  1. public class RandomWithWeight {

  2.         static class  Node {
  3.                 String val;
  4.                 int weight;
  5.                 public Node(String val, int i) {
  6.                         this.val = val;
  7.                         this.weight = i;
  8.                 }
  9.         }
  10.         public static String getRandomWithWeight(Node[] nodes) {
  11.                 for (int i = 1; i < nodes.length; i++) {
  12.                         nodes[i].weight = nodes[i - 1].weight + nodes[i].weight;
  13.                 }
  14.                 int len = nodes.length;
  15.                 double index = Math.random() * nodes[len - 1].weight;
  16.                 int res = binarySearch(index, nodes);
  17.                 return nodes[res].val;
  18.         }
  19.         private static int binarySearch(double index, Node[] nodes) {
  20.                 int start = 0;
  21.                 int end = nodes.length;
  22.                 while (start + 1 < end) {
  23.                         int mid = (end - start) / 2 + start;
  24.                         if (nodes[mid].weight  <= index) {
  25.                                 start = mid;
  26.                         } else {
  27.                                 end = mid;
  28.                         }
  29.                 }
  30.                 if (nodes[start].weight > index) {
  31.                         return start;
  32.                 } else {
  33.                         return end;
  34.                 }
  35.         }
  36.        
  37.         public static void main(String[] args) {
  38.                 int countA = 0;
  39.                 int countB = 0;
  40.                 int countC = 0;
  41.                 for (int i = 0; i < 6000; i++) {
  42.                         Node[] nodes = {new Node("a", 1), new Node("b", 2), new Node("c", 3)};
  43.                         String res = getRandomWithWeight(nodes);
  44.                         if (res.equals("a")) {
  45.                                 countA++;
  46.                         } else if (res.equals("b")) {
  47.                                 countB++;
  48.                         } else if (res.equals("c")) {
  49.                                 countC++;
  50.                         }
  51.                 }
  52.                 System.out.println(countA + " " + countB + " " + countC);
  53.         }
  54. }
复制代码
回复

使用道具 举报

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

本版积分规则

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