摘要:
题目:Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes.The lowest common ancestor is the node with la... 阅读全文
posted @ 2015-09-17 14:48
Nily
阅读(597)
评论(0)
推荐(0)
摘要:
题目:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.ExampleGiven the below binary tree: 1 / \2 3re... 阅读全文
posted @ 2015-09-17 11:28
Nily
阅读(165)
评论(0)
推荐(0)
摘要:
题目:给一副扑克牌和一个随机数函数,设计一个洗牌算法。解析:最直观的思路是什么?很简单,每次从牌堆中随机地拿一张出来。那么,第一次拿有52种可能,拿完后剩下51张;第二次拿有51种可能,第三次拿有50种可能,…,一直这样随机地拿下去直到拿完最后1张,我们就从52!种可能中取出了一种排列,这个排列对应... 阅读全文
posted @ 2015-09-17 11:21
Nily
阅读(657)
评论(0)
推荐(0)

浙公网安备 33010602011771号