由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 刚看了geekforgeek烙印代码果然一坨屎逻辑混乱
相关主题
讨论一下LCA的最好算法G家intern电面新鲜面经
一个老题binary tree找 lowest common ancestor 的code (请教求教Leetcode题目:Lowest Common Ancestor
Lowest common ancestor of two nodes of Binary Tree问一个LCA问题
least common ancestor的疑惑微软电面题
Lowest Common Ancestor in a binary tree (no parent pointer)LCA 问题
发几个面经(4) Amazon电面LCA的问题
讨论 Lowest common ancestor of BST请问关于lowest common ancestor的问题。
T电面面经请问如何求binary tree的lowest common ancestor
相关话题的讨论汇总
话题: ancestors话题: map话题: null话题: val
进入JobHunting版参与讨论
1 (共1页)
H**********5
发帖数: 2012
1
lowest common ancestor with parent.
看了这行:
if(ancestor.containsKey(q)!=ancestor.isEmpty())
我第一遍是觉得晕的
H**********5
发帖数: 2012
2
whole code:
package Interview.PhoneInterview.LinkedIn.Tree.BTree.Recurse.
LowestCommonAncestor;
import java.util.HashMap;
import java.util.Map;
class BTreeNodeWithParent{

int val;
BTreeNodeWithParent left;
BTreeNodeWithParent right;
BTreeNodeWithParent parent;
BTreeNodeWithParent(int val){
this.val=val;
this.left=this.right=this.parent=null;
}
}
public class LowestCommonAncestorOfABinaryTreeWithParent {
BTreeNodeWithParent LCA(BTreeNodeWithParent p, BTreeNodeWithParent q)
{
// Creata a map to store ancestors of n1
Map ancestors = new HashMap<
BTreeNodeWithParent, Boolean>();

// Insert n1 and all its ancestors in map
while (p != null)
{
ancestors.put(q, Boolean.TRUE);
p = p.parent;
}

// Check if n2 or any of its ancestors is in
// map.
while (q != null)
{
if (ancestors.containsKey(q) != ancestors.isEmpty())
return q;
q = q.parent;
}
return null;
}
}
A*******5
发帖数: 690
3
我还见过不会使用for 循环,五个同样的block,就是index不一样。还有号称有7年经
验的Web developer不知道在eclipse里新建JSP文件是选JSP Page还是JSP tag。。。当
然它可以说自己从来没用过eclipse
H**********5
发帖数: 2012
4
这种傻逼烙印轻松的进去了,因为人烙印经理照。老中呢?lc刷的bug free 都难得进。

【在 A*******5 的大作中提到】
: 我还见过不会使用for 循环,五个同样的block,就是index不一样。还有号称有7年经
: 验的Web developer不知道在eclipse里新建JSP文件是选JSP Page还是JSP tag。。。当
: 然它可以说自己从来没用过eclipse

1 (共1页)
进入JobHunting版参与讨论
相关主题
请问如何求binary tree的lowest common ancestorLowest Common Ancestor in a binary tree (no parent pointer)
Lowest Common Ancestor (LCA) The tree is not a binary tree发几个面经(4) Amazon电面
LCA时间讨论 Lowest common ancestor of BST
问道G题(3)T电面面经
讨论一下LCA的最好算法G家intern电面新鲜面经
一个老题binary tree找 lowest common ancestor 的code (请教求教Leetcode题目:Lowest Common Ancestor
Lowest common ancestor of two nodes of Binary Tree问一个LCA问题
least common ancestor的疑惑微软电面题
相关话题的讨论汇总
话题: ancestors话题: map话题: null话题: val