Redian新闻
>
刚看了geekforgeek烙印代码果然一坨屎逻辑混乱
avatar
刚看了geekforgeek烙印代码果然一坨屎逻辑混乱# JobHunting - 待字闺中
H*5
1
lowest common ancestor with parent.
看了这行:
if(ancestor.containsKey(q)!=ancestor.isEmpty())
我第一遍是觉得晕的
avatar
H*5
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;
}
}
avatar
A*5
3
我还见过不会使用for 循环,五个同样的block,就是index不一样。还有号称有7年经
验的Web developer不知道在eclipse里新建JSP文件是选JSP Page还是JSP tag。。。当
然它可以说自己从来没用过eclipse
avatar
H*5
4
这种傻逼烙印轻松的进去了,因为人烙印经理照。老中呢?lc刷的bug free 都难得进。

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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。