回复: 15
跳转到指定楼层
上一主题 下一主题
收起左侧

Google实习面经

全局:

2018(1-3月) 码农类General 博士 实习@google - 内推 - 技术电面  | | Other | 应届毕业生

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

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

x
刚结束加面。
第一轮:给一个API来判定node是不是erase的。然后把erase该node之后的所有tree都打印出来。只需要输出每个子树的root结点就行。这道题做的各种懵圈,详情不写了(哭)应该是挂了。
第二轮:幸运碰见华人小哥哥。两道题都很简单。第一题一个先上升后下降序列,求最高点的元素。各种Corner case需要考虑清楚。第二题是判断是个tree是不是same tree。same tr
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
,第二天整个人都有点晕晕的。。。。。

Timeline:
一月初内推,一月中投简历。
2月27:两轮店面,两天后通知加面。
3月14:加面(悬了)

能过算我走运。。。不能过也是自己实力不够。。。继续加油


上一篇:脸书 Data Engineer 新鲜面筋回报地里
下一篇:破你二抡垫面
推荐
lf963 2018-3-29 08:32:31 | 只看该作者
全局:
第一輪
  1. import java.util.*;
  2. public class RemoveTreeNode {
  3.     public static void main(String[] args){
  4.         RemoveTreeNode m = new RemoveTreeNode();

  5.         TreeNode root = new TreeNode(1);
  6.         TreeNode n2 = new TreeNode(2);
  7.         TreeNode n3 = new TreeNode(3);
  8.         TreeNode n4 = new TreeNode(4);
  9.         TreeNode n5 = new TreeNode(5);
  10.         TreeNode n6 = new TreeNode(6);
  11.         TreeNode n7 = new TreeNode(7);
  12.         TreeNode n8 = new TreeNode(8);

  13.         root.left = n2;
  14.         root.right = n3;
  15.         n2.left = n4;
  16.         n2.right = n5;
  17.         n3.right = n6;
  18.         n6.left = n7;
  19.         n6.right = n8;

  20.         //            1
  21.         //         /     \
  22.         //        2       3
  23.         //       / \       \
  24.         //      4   5       6
  25.         //                 /  \
  26.         //                7   8


  27.         System.out.println("Preorder of original tree");
  28.         m.preOrder(root);
  29.         System.out.println();
  30.         System.out.println("------------------------");


  31.         System.out.println("After remove some nodes");
  32.         List<TreeNode> ans = m.removeTreeNode(root);
  33.         for(TreeNode node : ans){
  34.             m.preOrder(node);
  35.             System.out.println();
  36.             System.out.println("------------------------");
  37.         }
  38.     }

  39.     List<TreeNode> removeTreeNode(TreeNode root){
  40.         ArrayList<TreeNode> ans = new ArrayList<TreeNode>();
  41.         TreeNode pseudoNode = new TreeNode(-1);
  42.         //Because pseudoNode is created by us,
  43.         //it's impossible for removeAPI to remove this node
  44.         //We create pseudoNode just in case of that removeAPI may remove the root of the tree
  45.         pseudoNode.left = root;
  46.         DFS(pseudoNode,ans);
  47.         if(pseudoNode.left != null)
  48.             ans.add(pseudoNode.left);
  49.         return ans;
  50.     }

  51.     //the return value of DFS() means whether we want to remove the children or not
  52.     boolean DFS(TreeNode node, ArrayList<TreeNode> ans){
  53.         if(node == null)
  54.             return false;   //don't have to remove this node
  55.         boolean removeLeft = DFS(node.left,ans);
  56.         boolean removeRight = DFS(node.right,ans);
  57.         if(removeLeft)
  58.             node.left = null;
  59.         if(removeRight)
  60.             node.right = null;
  61.         if(removeAPI(node)){    //removeAPI says we have to remove this node
  62.             if(node.left != null)
  63.                 ans.add(node.left);
  64.             if(node.right != null)
  65.                 ans.add(node.right);
  66.             return true;    //remove this node
  67.         }
  68.         return false;   //removeAPI doesn't say we have to remove this node
  69.     }

  70.     //I use this function to simulate removeAPI
  71.     boolean removeAPI(TreeNode node){
  72.         //remove nodes whose values are 1, 3, 6
  73.         if( node.val == 1 || node.val == 3  || node.val == 6 )
  74.             return true;
  75.         return false;
  76.     }

  77.     void preOrder(TreeNode node){
  78.         if(node == null)
  79.             return;
  80.         System.out.print(node.val + " ");
  81.         preOrder(node.left);
  82.         preOrder(node.right);
  83.     }
  84. }

  85. class TreeNode{
  86.     int val;
  87.     TreeNode left;
  88.     TreeNode right;
  89.     TreeNode(int val){
  90.         this.val = val;
  91.     }
  92. }
复制代码
回复

使用道具 举报

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

使用道具 举报

🔗
edyyy 2018-3-16 08:03:56 | 只看该作者
全局:
2月27:两轮店面 是背靠背吗?我觉得吃不消啊
回复

使用道具 举报

🔗
tinylic 2018-3-16 08:18:35 | 只看该作者
全局:
加面第二题是维护每个节点开始的最长递增和递减路径长度吗?
回复

使用道具 举报

🔗
 楼主| get_bits 2018-3-16 12:49:39 | 只看该作者
全局:
tinylic 发表于 2018-3-16 08:18
加面第二题是维护每个节点开始的最长递增和递减路径长度吗?

是的  存在重复元素。 字数字数
回复

使用道具 举报

🔗
 楼主| get_bits 2018-3-16 12:58:09 | 只看该作者
全局:
edyyy 发表于 2018-3-16 08:03
2月27:两轮店面 是背靠背吗?我觉得吃不消啊

不都是连续两轮的嘛。。。。。
回复

使用道具 举报

🔗
huzhouwjj 2018-3-20 06:47:02 | 只看该作者
全局:
请问第一轮的思路是什么呀?遇到需要erase的node,就把它的left tree/right tree算做一个subtree,并取消它和parent之间的关联?
回复

使用道具 举报

🔗
edyyy 2018-3-21 11:35:05 | 只看该作者
全局:
楼主加面完了吗?

补充内容 (2018-3-21 11:36):
我是问结果出来了吗?有点像知道啊
回复

使用道具 举报

🔗
lf963 2018-3-29 14:29:30 | 只看该作者
全局:
第二题是判断是个tree是不是same tree。same tree定义包含了完全相同和镜像两种。

有點不太懂,是給兩棵Tree嗎?
回复

使用道具 举报

🔗
lf963 2018-4-2 07:14:41 | 只看该作者
全局:
求一个序列中最长递增序列的长度

是LeetCode 300嗎?
回复

使用道具 举报

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

本版积分规则

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