秒拍机器学习社招面经分享

技术面:(面试问题主要围绕的是工作经历中的项目展开的。)
1、项目介绍;每个项目具体做了什么,项目内容问的很具体很仔细。
2、项目中遇到的难点与解决方案。这里当时还聊到了随机森林算法的随机性问题。
3、重点考察了一下算法和数据结构的基础知识
4、问了些栈和队列的处理相关问题
5、还问了我会不会利用git进行版本控制等等。
6、还问了一道算法题:
给定一棵二叉树,找到两个节点的最近公共父节点(LCA)。
最近公共祖先是两个节点的公共的祖先节点且具有最大深度。
假设给出的两个节点都在树中存在。

样例 1:
输入:{1},1,1
输出:1
解释:
二叉树如下(只有一个节点):
1
LCA(1,1) = 1


样例 2:
输入:{4,3,7,#,#,5,6},3,5
输出:4
解释:
二叉树如下:

4
/ \
3   7
/ \
5   6

LCA(3, 5) = 4

代码如下:
Version : Divide & Conquer

public class Solution {
    // 在root为根的二叉树中找A,B的LCA:
    // 如果找到了就返回这个LCA
    // 如果只碰到A,就返回A
    // 如果只碰到B,就返回B
    // 如果都没有,就返回null
    public TreeNode lowestCommonAncestor(TreeNode root, TreeNode node1, TreeNode node2) {
        if (root == null || root == node1 || root == node2) {
            return root;
        }
        
        // Divide
        TreeNode left = lowestCommonAncestor(root.left, node1, node2);
        TreeNode right = lowestCommonAncestor(root.right, node1, node2);
        
        // Conquer
        if (left != null && right != null) {
            return root;
        } 
        if (left != null) {
            return left;
        }
        if (right != null) {
            return right;
        }
        return null;
    }
}



HR面:
1、对行业的规划,也就是说以后想在什么行业发展;
2、手里有没有其他offer,来一下科技的概率多大;
3、最后就是问期望薪酬了。

#机器学习##社招##面经##算法工程师#
全部评论
作者:唐黄心树 链接:https://www.nowcoder.com/discuss/427871 来源:牛客网 reeNode left = lowestCommonAncestor(root.left, node1, node2);         TreeNode right = lowestCommonAncestor(root.right, node1, node2);                   // Conquer         if (left != null && right != null) {             return root;         }          if (left != null) {             return left;
点赞 回复
分享
发布于 2020-05-16 14:36
不懂
点赞 回复
分享
发布于 2020-05-16 14:36
春招专场
校招火热招聘中
官网直投

相关推荐

1 4 评论
分享
牛客网
牛客企业服务