
二叉树遍历
文章平均质量分 76
jmspan
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 230. Kth Smallest Element in a BST(二叉搜索树中的第K个元素)
原题网址:https://leetcode.com/problems/kth-smallest-element-in-a-bst/ Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is原创 2016-04-05 11:16:32 · 1468 阅读 · 0 评论 -
LeetCode 226. Invert Binary Tree(反转二叉树)
原题网址:https://leetcode.com/problems/invert-binary-tree/ Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 思路:递归调用,对左右子节原创 2016-04-05 03:54:25 · 928 阅读 · 0 评论 -
LeetCode 98. Validate Binary Search Tree(校验二叉搜索树)
原题网址:https://leetcode.com/problems/validate-binary-search-tree/ Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtre原创 2016-05-23 00:39:15 · 528 阅读 · 0 评论 -
LeetCode 145. Binary Tree Postorder Traversal(二叉树后序遍历)
原题网址:https://leetcode.com/problems/binary-tree-postorder-traversal/ Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1原创 2016-05-26 01:31:28 · 557 阅读 · 0 评论 -
LeetCode 94. Binary Tree Inorder Traversal(二叉树的中序遍历)
原题网址:https://leetcode.com/problems/binary-tree-inorder-traversal/ Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1原创 2016-05-23 00:35:01 · 1043 阅读 · 0 评论 -
LeetCode 285. Inorder Successor in BST
原题网址:https://leetcode.com/problems/inorder-successor-in-bst/ Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in原创 2016-04-15 00:35:29 · 1266 阅读 · 0 评论 -
LeetCode 117. Populating Next Right Pointers in Each Node II(右邻)
原题网址:https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/ Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any bina原创 2016-05-24 00:19:44 · 513 阅读 · 0 评论 -
LeetCode 99. Recover Binary Search Tree(修复二叉搜索树)
原题网址:https://leetcode.com/problems/recover-binary-search-tree/ Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A sol原创 2016-05-23 00:39:29 · 650 阅读 · 0 评论 -
LeetCode 366. Find Leaves of Binary Tree
原题网址:https://leetcode.com/problems/find-leaves-of-binary-tree/ Given a binary tree, find all leaves and then remove those leaves. Then repeat the previous steps until the tree is empty. Example:原创 2016-06-26 01:49:00 · 2746 阅读 · 0 评论 -
437. Path Sum III
原题网址:https://leetcode.com/problems/path-sum-iii/ You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does原创 2016-10-27 01:42:32 · 689 阅读 · 0 评论 -
LeetCode 314. Binary Tree Vertical Order Traversal(二叉树垂直遍历)
原题网址:https://leetcode.com/problems/binary-tree-vertical-order-traversal/ Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column).原创 2016-04-22 02:19:07 · 6097 阅读 · 0 评论 -
LeetCode 298. Binary Tree Longest Consecutive Sequence(二叉树最长连续序列)
原题网址:https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/ Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence原创 2016-04-17 00:08:30 · 1343 阅读 · 0 评论 -
LeetCode 235. Lowest Common Ancestor of a Binary Search Tree(二叉搜索树的最低公共祖先)
原题网址:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/ Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. Accord原创 2016-04-06 06:33:46 · 712 阅读 · 0 评论 -
LeetCode 236. Lowest Common Ancestor of a Binary Tree(二叉树的最低公共祖先)
原题网址:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/ Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definiti原创 2016-04-06 06:43:21 · 1372 阅读 · 0 评论 -
LeetCode 222. Count Complete Tree Nodes(完全二叉树节点数统计)
本人原创,如有错误恳请指正,谢谢! 原题网址https://leetcode.com/problems/count-complete-tree-nodes/ Given a complete binary tree, count the number of nodes.原创 2016-04-04 13:01:11 · 4360 阅读 · 3 评论 -
LeetCode 107. Binary Tree Level Order Traversal II(二叉树分层遍历)
原题网址:https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by le原创 2016-05-24 00:12:44 · 477 阅读 · 0 评论 -
LeetCode 112. Path Sum(路径和)
原题网址:https://leetcode.com/problems/path-sum/ Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.原创 2016-05-24 00:18:59 · 513 阅读 · 0 评论 -
LeetCode 114. Flatten Binary Tree to Linked List(摊平二叉树)
原题网址:https://leetcode.com/problems/flatten-binary-tree-to-linked-list/ Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5原创 2016-05-24 00:19:26 · 542 阅读 · 0 评论 -
LeetCode 257. Binary Tree Paths
原题网址:https://leetcode.com/problems/binary-tree-paths/ Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5原创 2016-04-09 05:21:23 · 334 阅读 · 0 评论 -
LeetCode 255. Verify Preorder Sequence in Binary Search Tree(检查二叉搜索树的前序遍历)
原题网址:https://leetcode.com/problems/verify-preorder-sequence-in-binary-search-tree/ Given an array of numbers, verify whether it is the correct preorder traversal sequence of a binary search tree.原创 2016-04-09 04:44:06 · 1021 阅读 · 0 评论 -
LeetCode 144. Binary Tree Preorder Traversal(二叉树前缀遍历)
原题网址:https://leetcode.com/problems/binary-tree-preorder-traversal/ Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1原创 2016-05-26 01:57:11 · 592 阅读 · 0 评论 -
404. Sum of Left Leaves
原题网址:https://leetcode.com/problems/sum-of-left-leaves/ Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in t原创 2016-10-27 04:51:54 · 327 阅读 · 0 评论