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

Uber 电面 目测是跪了。。。

全局:

2015(10-12月) 码农类General 硕士 全职@uber - 内推 - 技术电面  | | Other | 在职跳槽

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

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

x
sigh 目测是跪了。。。
第一题是买卖股票1,两分钟写完

第二题是sort a deck
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
否要交换牌直到该位置的牌正确为止。。。

泪奔了。。。

上一篇:12/17 Qumulo 电面
下一篇:Square skype面

本帖被以下淘专辑推荐:

🔗
windream1991 2015-12-21 03:35:39 | 只看该作者
全局:
应该可以用桶排序o(n)解决
回复

使用道具 举报

🔗
jygan 2016-1-2 13:21:58 | 只看该作者
全局:
sort a deck of card那题可以用 bucket sort
回复

使用道具 举报

🔗
bobzhang2004 2016-1-12 00:29:03 | 只看该作者
全局:
写了写第二题代码
  1. public class SortDeckOfCard {
  2.         static class Card {
  3.                 int suite;
  4.                 int rank;

  5.                 public Card(int suite, int rank) {
  6.                         this.suite = suite;
  7.                         this.rank = rank;
  8.                 }
  9.         }

  10.         public static void sortDeckOfCard(Card[] cards) {
  11.                 if (cards == null || cards.length == 0) {
  12.                         return;
  13.                 }
  14.                 for (int i = 0; i < cards.length;) {
  15.                         int index = cards[i].suite * 13 + cards[i].rank;
  16.                         if (index >= 0 && index < 52
  17.                                         && (cards[index].suite * 13 + cards[index].rank != index)) {
  18.                                 Card tmp = cards[index];
  19.                                 cards[index] = cards[i];
  20.                                 cards[i] = tmp;
  21.                         } else {
  22.                                 i++;
  23.                         }
  24.                 }
  25.         }

  26.         public static void main(String[] args) {
  27.                 Card[] cards = new Card[52];
  28.                 for (int i = 0; i < 4; i++) {
  29.                         for (int j = 0; j < 13; j++) {
  30.                                 cards[51 - i * 13 - j] = new Card(i, j);
  31.                         }
  32.                 }
  33.                 for (int i = 0; i < 52; i++) {
  34.                         System.out.print((cards[i].suite * 13 + cards[i].rank) + " ");
  35.                 }
  36.                 System.out.println();
  37.                 sortDeckOfCard(cards);
  38.                 for (int i = 0; i < 52; i++) {
  39.                         System.out.print((cards[i].suite * 13 + cards[i].rank) + " ");
  40.                 }
  41.         }
  42. }
复制代码
回复

使用道具 举报

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

本版积分规则

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