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

🐶Google 面经,流程介绍

 
地里匿名用户
🔗
匿名用户-ODVOF  2022-6-16 12:53:54
感觉vo的第二轮第三轮的follow up都好难 请问大佬有思路吗???
回复

使用道具 举报

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

使用道具 举报

🔗
billyRandom 2022-6-26 04:49:43 | 只看该作者
全局:
VO 第三问楼主给的例子是12248326? 能解释一下由什么数变成12248326?
回复

使用道具 举报

🔗
neverlate 2022-6-28 08:40:24 | 只看该作者
全局:
已米,但是不太理解the newly expose node怎么定义,
麻烦楼主解释一下,谢谢。
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-XANRA  2022-6-29 05:44:10 来自APP
EngProd是干嘛的?
回复

使用道具 举报

全局:
billyRandom 发表于 2022-06-25 13:49:43
VO 第三问楼主给的例子是12248326? 能解释一下由什么数变成12248326?
你完全没看懂题目吧。。起始就是12啊 然后1*2=2 所以是122 然后2*2=4 所以是1224 etc.
回复

使用道具 举报

🔗
billyRandom 2022-6-29 06:17:19 | 只看该作者
全局:
Dionysus的酒 发表于 2022-6-28 15:00
你完全没看懂题目吧。。起始就是12啊 然后1*2=2 所以是122 然后2*2=4 所以是1224 etc.

啊这下明白了。这个问的第一个follow up 怎么用两个variable 做?
回复

使用道具 举报

🔗
Falldawn 2022-7-10 02:41:45 | 只看该作者
全局:
有点像拓扑排序。 需要从node到root重新建一个graph 和每一个node的indegree size.  再通过DFS的方式从入度为0的点遍历。

DFS遍历时比较麻烦,因为每次都改变了Map。所以每次都复制一个新的map修改传
  1. public List<List<Integer>> findLeaves(TreeNode root) {
  2.         List<List<Integer>> res = new ArrayList<>();
  3.         
  4.         Map<Integer, Integer> graph = new HashMap<>();
  5.         Map<Integer, Integer> indegreeMap = new HashMap<>();
  6.         Set<Integer> leafNodes = new HashSet<>();
  7.         
  8.         preOrder(root, graph, indegreeMap, leafNodes);
  9.         return res;
  10.     }
  11.    
  12.     private void preOrder(TreeNode cur, Map<Integer, Integer> graph, Map<Integer, Integer> indegreeMap, Set<Integer> leafNodes) {
  13.         if (cur == null) {
  14.             return;
  15.         }
  16.         
  17.         int degree = 0;
  18.         if (cur.left != null) {
  19.             graph.put(cur.left.val, cur.val);
  20.             degree++;
  21.         }
  22.         if (cur.right != null) {
  23.             graph.put(cur.right.val, cur.val);
  24.             degree++;
  25.         }
  26.         if (degree == 0) {
  27.             leafNodes.add(cur.val);
  28.         }
  29.         indegreeMap.put(cur.val, degree);
  30.         preOrder(cur.left, graph, indegreeMap, leafNodes);
  31.         preOrder(cur.right, graph, indegreeMap, leafNodes);
  32.     }
复制代码
回复

使用道具 举报

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

本版积分规则

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