随笔分类 -  CodingTrash

Coding + Game = Happiness! 不游戏,不coding,你怎会快乐?
摘要: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 卢泽尔 阅读(256) 评论(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 卢泽尔 阅读(182) 评论(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 卢泽尔 阅读(196) 评论(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 卢泽尔 阅读(346) 评论(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 卢泽尔 阅读(191) 评论(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 卢泽尔 阅读(176) 评论(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 卢泽尔 阅读(287) 评论(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 卢泽尔 阅读(217) 评论(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 卢泽尔 阅读(765) 评论(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 卢泽尔 阅读(179) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/Same idea to Convert Sorted Array to Binary Search Tree, but w... 阅读全文

posted @ 2014-05-22 06:46 卢泽尔 阅读(168) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/We design a auxilar function that convert a linked list to a no... 阅读全文

posted @ 2014-05-14 01:06 卢泽尔 阅读(186) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/balanced-binary-tree/We use a recursive auxilar function to determine whether a sub-tree is balanced, if ... 阅读全文

posted @ 2014-05-14 00:19 卢泽尔 阅读(364) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/minimum-depth-of-binary-tree/To find the minimum depth, we BFS from the root and record the depth. For ea... 阅读全文

posted @ 2014-05-13 22:53 卢泽尔 阅读(146) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/path-sum-ii/The basic idea here is same to that of Path Sum. However, since the problem is asking for all... 阅读全文

posted @ 2014-05-13 22:46 卢泽尔 阅读(194) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/path-sum/One solution is to BFS the tree from the root, and for each leaf we check if the path sum equals... 阅读全文

posted @ 2014-05-13 22:39 卢泽尔 阅读(246) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/The problem is asking for flatterning a binary tree to linked list by ... 阅读全文

posted @ 2014-05-13 22:19 卢泽尔 阅读(155) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/distinct-subsequences/A classic problem using Dynamic Programming technique.Let m and n be the length of ... 阅读全文

posted @ 2014-05-13 11:07 卢泽尔 阅读(178) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/OK... Exactly same to Populating Next Right Pointers in Ea... 阅读全文

posted @ 2014-05-13 10:09 卢泽尔 阅读(113) 评论(0) 推荐(0)

摘要:Problem Link:http://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/Just traverse the tree from the root, level by level. Esay en... 阅读全文

posted @ 2014-05-13 10:07 卢泽尔 阅读(206) 评论(0) 推荐(0)