📣 独立日限时特惠: VIP通行证立减$68
回复: 8
跳转到指定楼层
上一主题 下一主题
收起左侧

Google 电面+VO 详细behavioral questions

🔗
匿名用户-K5W1O  2022-7-11 03:18:23 |倒序浏览

2022(4-6月) 码农类General 本科 全职@google - 内推 - 技术电面 Onsite  | 😐 Neutral 😐 Average | Other | 在职跳槽

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

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

x
楼主转码,面的Early career

电面:先是设计classes for a custom word string tree (类似trie但是要区分中间node vs leaf node两个不同的class,而且要记录子树里存的string总长度)。然后再实现一个method找从前往后数tree里存的第n个letter。
VO:
第一轮 googliness / BQ:
  • tell me something interestin
    您好!
    本帖隐藏的内容需要积分高于 188 才可浏览
    您当前积分为 0。
    使用VIP即刻解锁阅读权限或查看其他获取积分的方式
    游客,您好!
    本帖隐藏的内容需要积分高于 188 才可浏览
    您当前积分为 0。
    VIP即刻解锁阅读权限查看其他获取积分的方式
    Unlock interview details and practice with AI
    Curated Interview Questions from Top Companies
    三轮:基本上就是写个splitwise的逻辑。一开始不要求交易数量最小。用了两种方法写,写完后没时间了就没问follow up。但我知道follow up是利口斯溜舞,估计问了我也当场做不出来

    第四轮:利口尔伞揪

    焦急等待结果中。。。希望能过,求加米






评分

参与人数 7大米 +24 收起 理由
bryanjhy + 10 给你点个赞!
StellaQCIT + 1 赞一个
chao00440 + 1 赞一个
匿名用户-DUT19 + 8
Falldawn + 1 给你点个赞!

查看全部评分


上一篇:DoorDash 电面+VO
下一篇:不新鲜隔夜香蕉OA过经
🔗
5222464 2022-7-11 04:07:45 | 只看该作者
全局:
楼主是怎么记得题号的呢 我只记得有这么道题 但是记不住题号
回复

使用道具 举报

🔗
5222464 2022-7-11 04:07:59 | 只看该作者
全局:
店面可以给个例子吗
回复

使用道具 举报

🔗
neverlate 2022-7-11 07:18:01 | 只看该作者
全局:
已米,有几个问题请教一下:
1
再实现一个method找从前往后数tree里存的第n个letter,这个有点不理解
假设对英语的26个小写字母做trie,那从前往后的第n个是,depth的深度吗?

2
linkedlist 通过改value删除,是把后续的node val覆盖这个被删除的,一直到结束,
如果是最后一个node,那就直接删掉,对不对?

删除倒数的第n个node,我能想到的是2 pointers,如果有啥更好的方法,请指教。

3 你面的是swe还是mle
这问题你是怎么回答的:say you were the product manager overseeing the creation of a new smile detection ML feature, how do you go about gathering the data needed?

回复

使用道具 举报

🔗
Falldawn 2022-7-11 08:28:25 | 只看该作者
全局:
neverlate 发表于 2022-7-10 16:18
已米,有几个问题请教一下:
1
再实现一个method找从前往后数tree里存的第n个letter,这个有点不理解

第一题出现过多次,

A cord tree is a binary tree of strings.
A node in this tree can be a leaf node or an internal node.
An internal node has two children, a left child and a right child. It also has a length of all the children under it
A leaf nodes have a value and a length
                               #      InternalNode, 26
                                #      /              \   
                                #     /                \                        
                                #    /                  \
                                # Leaf(5, ABCDE)      InternalNode, 21
                                #                       /           \
                                #                      /             \
                                #                     /               \
                                #                    /                 \
                                #         Leaf(10, FGHIJKLMNO)     Leaf(11, PQRSTUVWXYZ)  

Q1: Define a Data Structure that represents a Cord tree.
Q2: Define a function that takes in a tree and an index and returns the character at that index.

具体请看下面答案
https://leetcode.com/discuss/interview-question/413991/
回复

使用道具 举报

🔗
Falldawn 2022-7-12 06:06:12 | 只看该作者
全局:
第三轮请问楼主用哪2种方法做的?

下面我用2个PQ来做的

注意斯溜舞给出的是交易,我们需要返回的是 int[] {a, b, num}也就是a 还给b $num
  1. public List<int[]> minTransfers(int[][] transactions) {

  2.         // Key: person's ID   Value: person's balance after calculation
  3.         // {1 : -5} means person 1 should get $5
  4.         // {2 : 10} means person 2 should pay $10
  5.         Map<Integer, Integer> map = new HashMap<>();
  6.         for (int[] trans : transactions) {
  7.             map.put(trans[0], map.getOrDefault(trans[0], 0) - trans[2]);
  8.             map.put(trans[1], map.getOrDefault(trans[1], 0) + trans[2]);
  9.         }

  10.         // Since after we get those amount of balance, person's ID does not affect the final result
  11.         PriorityQueue<int[]> ownHeap = new  PriorityQueue<>((a, b) -> Integer.compare(b[1], a[1])); // debt owner
  12.         PriorityQueue<int[]> colHeap = new PriorityQueue<>((a, b) -> Integer.compare(b[1], a[1])); // debt collector
  13.         int n = map.size(), i = 0;
  14.         int[] balance = new int[n];
  15.         for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
  16.             int id = entry.getKey();
  17.             int bal = entry.getValue();
  18.             balance[id] = bal;
  19.             if (bal > 0) {
  20.                 ownHeap.offer(new int[]{id, bal});
  21.             } else if (bal < 0) {
  22.                 colHeap.offer(new int[]{id, -bal});
  23.             }
  24.         }
  25.         List<int[]> res = new ArrayList<>();
  26.         while (!ownHeap.isEmpty() && !colHeap.isEmpty()) {
  27.             int[] curOwner = ownHeap.poll();
  28.             int curOwnerId = curOwner[0];
  29.             int curOwnerNum = curOwner[1];
  30.             int[] curCollector = colHeap.poll();
  31.             int curCollectorId = curCollector[0];
  32.             int curCollectorNum = curCollector[1];
  33.             int sum = curOwnerNum - curCollectorNum;
  34.             if (sum > 0) {
  35.                 ownHeap.offer(new int[]{curOwnerId, sum});
  36.                 res.add(new int[]{curOwnerId, curCollectorId, curCollectorNum});
  37.             } else if (sum < 0) {
  38.                 colHeap.offer(new int[]{curCollectorId, -sum});
  39.                 res.add(new int[]{curOwnerId, curCollectorId, curOwnerNum});
  40.             } else if (sum == 0) {
  41.                 res.add(new int[]{curOwnerId, curCollectorId, curOwnerNum});
  42.             }
  43.         }

  44.         return res;
  45.     }
复制代码
回复

使用道具 举报

🔗
Falldawn 2022-7-12 06:40:42 | 只看该作者
全局:
sort后双指针
  1. public List<int[]> transfers(int[][] transactions) {
  2.         // Key: person's ID   Value: person's balance after calculation
  3.         // {1 : -5} means person 1 should get $5
  4.         // {2 : 10} means person 2 should pay $10
  5.         Map<Integer, Integer> map = new HashMap<>();
  6.         for (int[] trans : transactions) {
  7.             map.put(trans[0], map.getOrDefault(trans[0], 0) - trans[2]);
  8.             map.put(trans[1], map.getOrDefault(trans[1], 0) + trans[2]);
  9.         }

  10.         List<int[]> balances = new ArrayList<>();
  11.         for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
  12.             int id = entry.getKey();
  13.             int bal = entry.getValue();
  14.             balances.add(new int[]{id, bal});
  15.         }
  16.         Collections.sort(balances,(a, b) -> Integer.compare(a[1], b[1]));

  17.         List<int[]> res = new ArrayList<>();
  18.         for (int i = 0, j = balances.size() - 1; i < j; ) {
  19.             int[] p1 = balances.get(i);
  20.             int[] p2 = balances.get(j);
  21.             int p1Id = p1[0];
  22.             int p1Num = p1[1];
  23.             int p2Id = p2[0];
  24.             int p2Num = p2[1];
  25.             if (p1Num == 0) {
  26.                 i++;
  27.                 continue;
  28.             }
  29.             if (p1Num == 0) {
  30.                 j--;
  31.                 continue;
  32.             }
  33.             int sum = p1Num + p2Num; // x < 0, y > 0
  34.             if (sum == 0) {
  35.                 res.add(new int[]{p2Id, p1Id, p2Num});
  36.                 i++;
  37.                 j--;
  38.             }else if (sum > 0) {
  39.                 res.add(new int[]{p2Id, p1Id, -p1Num});
  40.                 i++;
  41.             } else {
  42.                 res.add(new int[]{p2Id, p1Id, p2Num});
  43.                 j--;
  44.             }
  45.         }

  46.         return res;
  47.     }
复制代码
回复

使用道具 举报

🔗
cailucun 2022-7-18 06:39:40 | 只看该作者
全局:
Falldawn 发表于 2022-7-11 16:06
第三轮请问楼主用哪2种方法做的?

下面我用2个PQ来做的

请问greedy不能确保是最少的transfer对吧?
回复

使用道具 举报

🔗
Falldawn 2022-7-18 23:56:21 | 只看该作者
全局:
cailucun 发表于 2022-7-17 15:39
请问greedy不能确保是最少的transfer对吧?

肯定不能
回复

使用道具 举报

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

本版积分规则

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