摘要:
Problem statement:Thought: Since TreeNode has a self-recursive structure, it's very natural and easy to come up with a recursive implement. But the tricky part is how to implement this using a iterative method. The three binary tree traversal methods: pre-order, in-order and post-order can all b 阅读全文
posted @ 2014-04-10 04:41
门对夕阳
阅读(952)
评论(0)
推荐(0)
摘要:
Binary Tree的三种Traversal方法老是记混,故于此总结下。Preorder: Node -> Left subtree -> Right subtreeInorder: Left subtree -> Node -> Right subtreePostorder: Left subtree -> Right subtree -> NodePre, In, Post指的是Node本身在[Node, Left, Right]中被访问的顺序。Pre is 1st, In is 2nd, Post is 3rd.Note: Inorder trave 阅读全文
posted @ 2014-04-10 03:08
门对夕阳
阅读(117)
评论(0)
推荐(0)
摘要:
Problem:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.set(key, value)- Set or insert the value if the key 阅读全文
posted @ 2014-04-10 02:58
门对夕阳
阅读(363)
评论(0)
推荐(0)

浙公网安备 33010602011771号