2014年5月27日

摘要: Problem Link:https://oj.leetcode.com/problems/validate-binary-search-tree/We inorder-traverse the tree, and for each node we check if current_node.val... 阅读全文

posted @ 2014-05-27 05:59 卢泽尔 阅读(251) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/recover-binary-search-tree/We know that the inorder traversal of a binary search tree should be a sorted... 阅读全文

posted @ 2014-05-27 05:52 卢泽尔 阅读(181) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/same-tree/The following recursive version is accepted but the iterative one is not accepted...# Definiti... 阅读全文

posted @ 2014-05-27 05:09 卢泽尔 阅读(195) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/symmetric-tree/To solve the problem, we can traverse the tree level by level. For each level, we constru... 阅读全文

posted @ 2014-05-27 04:56 卢泽尔 阅读(341) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/binary-tree-level-order-traversal/Traverse the tree level by level using BFS method.# Definition for a ... 阅读全文

posted @ 2014-05-27 04:38 卢泽尔 阅读(189) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/Just BFS from the root and for each level insert a list of valu... 阅读全文

posted @ 2014-05-27 04:36 卢泽尔 阅读(170) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/Simply BFS from root and count the number of levels. The code is as follows... 阅读全文

posted @ 2014-05-27 04:30 卢泽尔 阅读(284) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/The basic idea is same to that for Construct B... 阅读全文

posted @ 2014-05-27 04:26 卢泽尔 阅读(212) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/This problem can be easily solved using recur... 阅读全文

posted @ 2014-05-27 04:17 卢泽尔 阅读(759) 评论(0) 推荐(0)

摘要: Problem Link:https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/Use BFS from the tree root to traverse the tree level by level. The... 阅读全文

posted @ 2014-05-27 02:22 卢泽尔 阅读(177) 评论(0) 推荐(0)