📣 Back to School开学季 - VIP通行证5折优惠!蓝莓、Offer多多同步优惠
回复: 31
跳转到指定楼层
上一主题 下一主题
收起左侧

Google 11月19号 实习面经 和 12月18号 旁观面经

全局:

2015(10-12月) 码农类General 硕士 实习@google - 内推 - 技术电面  | | Fail | 应届毕业生

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

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

x
面完很久了,今天来把题目贴一下,希望对后面面试的同学有帮助。

第一轮:
感觉是中国人,二话不说贴题,应该是挂在这轮了,还有15分钟贴上第三题 T_T 没写完,当时就感觉完蛋了
Q1: Assume you have a deck of cards. Each card has a number on it with no suit. We define “X of a kind” as X cards with same number on it (X >= 2). Determine if the deck can be fully divided into sets of “X of a kind”.
Example: 3, 5, 3, 5, 3 -> True
3, 3, 5, 3, 3 -> False
Q2: Define “Straight” as 5 cards with consecutive numbers. Determine if the deck can be fully divided into sets of “Straight”.
Example: 1, 2, 3, 4, 4, 5, 5, 6,
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
Copy with random pointer
[size=13.3333px]
[size=13.3333px]😂面试过程超搞笑,在学校图书馆面,第一轮的时候一个小哥过来说这屋子我预定了,你出去,阿三哥:求你别让我走..我在面试...
[size=13.3333px]第二轮的时候火警响了,好像今天学校火警演练,来了三拨人说你不要命了,赶紧出去,阿三哥:求你别让我走...我在面试...

评分

参与人数 3大米 +28 收起 理由
pengzewen37 + 15 感谢分享!
xzcode + 10 感谢分享!
hulahu + 3 感谢分享!

查看全部评分


上一篇:Amazon OA2 12/18 due
下一篇:Twitter店面

本帖被以下淘专辑推荐:

推荐
singku 2016-1-7 12:46:41 | 只看该作者
全局:
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. #include <list>
  5. #include <algorithm>
  6. #include <sstream>

  7. using namespace std;

  8. bool can_divide_x_kind(std::vector<int> input)
  9. {
  10.     std::map<int, int> htable;
  11.     for (int i = 0; i < input.size(); i++) {
  12.         htable[input[i]] ++;
  13.     }

  14.     std::map<int, int>::iterator it = htable.begin();
  15.     for (; it != htable.end(); it++) {
  16.         if (it->second < 2) {
  17.             return false;
  18.         }
  19.     }
  20. }

  21. bool can_divide_5straight(std::vector<int> input)
  22. {
  23.     std::map<int, int> htable;
  24.     for (int i = 0; i < input.size(); i++) {
  25.         htable[input[i]] ++;
  26.     }

  27.     while (htable.size() >= 5) {
  28.         std::map<int, int>::iterator it = htable.begin();

  29.         int val = it->first;
  30.         it->second--;
  31.         if (it->second == 0) {
  32.             htable.erase(it++);
  33.         } else {
  34.             it++;
  35.         }
  36.         for (int i = 0; i < 4; i++) {
  37.             int val1 = it->first;
  38.             if (val1 = val + 1) {
  39.                 it->second--;
  40.                 if (it->second == 0) {
  41.                     htable.erase(it++);
  42.                 } else {
  43.                     val = val1;
  44.                     it++;
  45.                 }
  46.             } else {
  47.                 return false;
  48.             }
  49.         }   
  50.     }

  51.     if (htable.size()) {
  52.         return false;
  53.     }
  54.     return true;
  55. }

  56. string list_to_string(std::list<int> list)
  57. {
  58.     ostringstream oss;
  59.     std::list<int>::iterator it = list.begin();
  60.     for (; it != list.end(); it++) {
  61.         oss << *it;
  62.     }
  63.     return oss.str();
  64. }

  65. int call = 0;
  66. int ret = 0;
  67. std::map<string, bool> memoized;
  68. bool can_divide_x_straight(std::list<int> input)
  69. {
  70.     call++;
  71.     string str = list_to_string(input);
  72.     if (memoized.count(str)) {
  73.         ret++;
  74.         return memoized[str];
  75.     }

  76.     if (input.size() <= 2) {
  77.         return false;
  78.     }

  79.     for (int i = 3; i <= input.size(); i++) {
  80.         
  81.         std::list<int> copy = input;
  82.         std::list<int>::iterator it = copy.begin();
  83.         std::list<int>::iterator it1;
  84.         bool impossible = false;
  85.         for (int j = 1; j <= i-1; j++) {
  86.             it1 = it;
  87.             while (*it1 == *it && it1 != copy.end()) {
  88.                 it1++;
  89.             }
  90.             if (it1 == copy.end()) {
  91.                 impossible = true;
  92.                 break;
  93.             }
  94.             if (*it1 != *it + 1) {
  95.                 impossible = true;
  96.                 break;
  97.             }
  98.             copy.erase(it);
  99.             it = it1;
  100.         }
  101.         if (impossible == true) {
  102.             continue;
  103.         }
  104.         copy.erase(it);
  105.         if (copy.size() == 0 || can_divide_x_straight(copy)) {
  106.             string str = list_to_string(input);
  107.             memoized[str] = true;
  108.             return true;
  109.         }
  110.     }
  111.     str = list_to_string(input);
  112.     memoized[str] = false;
  113.     return false;
  114. }

  115. bool comp(int i, int j) {
  116.     return i<j;
  117. }

  118. int main(void)
  119. {
  120.     int vec[] = {
  121.         1,1,2,2,3,3,4,4,5,5,5
  122.     };

  123.     std::vector<int> input(vec, vec + sizeof(vec)/sizeof(int));
  124.     std::sort(input.begin(), input.end(), comp);   

  125.     std::list<int> input1(vec, vec+ sizeof(vec)/sizeof(int));
  126.     std::sort(input.begin(), input.end(), comp);

  127.     if (can_divide_x_kind(input)) {
  128.         cout << "1_good" <<endl;
  129.     }

  130.     if (can_divide_5straight(input)) {
  131.         cout << "2_good" << endl;
  132.     }

  133.     if (can_divide_x_straight(input1)) {
  134.         cout << "3_good" << " " << call << " " << ret << endl;
  135.     } else {
  136.         cout << call << " " << ret << endl;
  137.     }
  138.     return 0;
  139. }
复制代码
回复

使用道具 举报

全局:
写了下第一轮第二问,楼主可以详细讲讲第三问怎么做吗?
  1. public class Straight {
  2.        
  3.         static class Point {
  4.                 int val;
  5.                 int count;
  6.                
  7.                 public Point(int val, int count) {
  8.                         this.val = val;
  9.                         this.count = count;
  10.                 }
  11.         }
  12.         public static boolean isExactXStraight(int[] nums, int x) {
  13.                 if (nums == null || nums.length < x) {
  14.                         return false;
  15.                 }
  16.                 PriorityQueue<Point> pq = new PriorityQueue<Point>(11, new Comparator<Point>() {
  17.                         public int compare(Point p1, Point p2) {
  18.                                 return p1.val - p2.val;
  19.                         }
  20.                 });
  21.                 HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
  22.                 for (int i : nums) {
  23.                         if (map.containsKey(i)) {
  24.                                 map.put(i, map.get(i) + 1);
  25.                         } else {
  26.                                 map.put(i, 1);
  27.                         }
  28.                 }
  29.                 for (int key : map.keySet()) {
  30.                         pq.offer(new Point(key, map.get(key)));
  31.                 }
  32.                 while (!pq.isEmpty()) {
  33.                         List<Point> list = new ArrayList<Point>();
  34.                         Point prev = pq.poll();
  35.                         list.add(prev);
  36.                         for (int i = 1; i < x; i++) {
  37.                                 if (pq.isEmpty()) {
  38.                                         return false;
  39.                                 }
  40.                                 Point cur = pq.poll();
  41.                                 list.add(cur);
  42.                                 if (cur.val != prev.val + 1) {
  43.                                         return false;
  44.                                 }
  45.                                 prev = cur;
  46.                         }
  47.                         for (Point p : list) {
  48.                                 p.count = p.count - 1;
  49.                                 if (p.count != 0) {
  50.                                         pq.offer(p);
  51.                                 }
  52.                         }
  53.                 }
  54.                
  55.                 return true;
  56.         }
  57.        
  58.         public static void main(String[] args) {
  59.                 int[] nums = {1, 2, 3, 4, 4, 5, 5, 6, 7, 8};
  60.                 boolean res = isExactXStraight(nums, 5);
  61.                 System.out.println(res);
  62.         }
  63. }
复制代码
回复

使用道具 举报

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

使用道具 举报

🔗
leixiang5 2015-12-19 06:30:04 | 只看该作者
全局:
这印度朋友太倒霉了吧。。。
回复

使用道具 举报

🔗
 楼主| bearcat001 2015-12-19 06:35:12 | 只看该作者
全局:
leixiang5 发表于 2015-12-19 06:30
这印度朋友太倒霉了吧。。。

这就是命... 面试官还问,要不先这样吧,火大不? =_= 最后时间到了还多给了他几分钟~
回复

使用道具 举报

🔗
leixiang5 2015-12-19 06:40:09 | 只看该作者
全局:
bearcat001 发表于 2015-12-19 06:35
这就是命... 面试官还问,要不先这样吧,火大不? =_= 最后时间到了还多给了他几分钟~

火警这么响。也能继续面啊。
回复

使用道具 举报

🔗
七夜雪 2015-12-19 06:42:30 | 只看该作者
全局:
maximum increasing subsequence是指longest increasing subsequence吗?In tree指的是tree的in-order traversal吗?
回复

使用道具 举报

🔗
 楼主| bearcat001 2015-12-19 06:42:41 | 只看该作者
全局:
leixiang5 发表于 2015-12-19 06:40
火警这么响。也能继续面啊。

火警演练,声音不是很大,也没有响很久。如果是真的火警那就说啥也得撤了 - -
回复

使用道具 举报

🔗
leixiang5 2015-12-19 06:47:33 | 只看该作者
全局:
bearcat001 发表于 2015-12-19 06:42
火警演练,声音不是很大,也没有响很久。如果是真的火警那就说啥也得撤了 - -

你朋友还真硬。。
我倒是遇过面试官的building火警。。重新安排面试了。。
回复

使用道具 举报

🔗
tanpf5 2015-12-19 09:23:17 | 只看该作者
全局:
straight那个题怎么实现?
回复

使用道具 举报

🔗
 楼主| bearcat001 2015-12-19 10:28:48 | 只看该作者
全局:
tanpf5 发表于 2015-12-19 09:23
straight那个题怎么实现?

你说的是哪一问?
回复

使用道具 举报

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

本版积分规则

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