
树
Wu_uuuu
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Leetcode-144. Binary Tree Preorder Traversal
题目Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [1,2,3].Note: Recursive solution is trivial, could you do it iteratively? 给原创 2017-04-03 22:00:39 · 260 阅读 · 0 评论 -
Leetcode-110. Balanced Binary Tree
题目Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ b原创 2017-04-04 11:03:05 · 248 阅读 · 0 评论 -
Leetcode-114. Flatten Binary Tree to Linked List
题目Given a binary tree, flatten it to a linked list in-place.For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \原创 2017-04-04 11:18:05 · 312 阅读 · 0 评论 -
Leetcode-104. Maximum Depth of Binary Tree
题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 求二叉树的最大深度代码class Solution {public:原创 2017-04-04 13:41:47 · 391 阅读 · 0 评论 -
Leetcode-111. Minimum Depth of Binary Tree
题目Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 求二叉树的最小深度:根节点到最近叶子节点的路径长度。代码class Solut原创 2017-04-04 13:35:47 · 323 阅读 · 0 评论 -
Leetcode-112. 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.For example: Given the below binary tree and sum =原创 2017-04-04 13:51:54 · 261 阅读 · 0 评论 -
Leetcode-113. Path Sum II
题目Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.For example: Given the below binary tree and sum = 22, 5 / \原创 2017-04-04 14:14:53 · 417 阅读 · 1 评论 -
Leetcode-116. Populating Next Right Pointers in Each Node
题目Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If原创 2017-04-04 14:34:15 · 285 阅读 · 0 评论 -
Leetcode-108. Convert Sorted Array to Binary Search Tree
题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 给定一个排序的数组,返回二叉排序树思路递归建立树即可代码class Solution {public: TreeNode* sortedArrayToBST(vector<int>& num原创 2017-04-18 19:12:08 · 215 阅读 · 0 评论 -
Leetcode-101. Symmetric Tree
题目Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric:1/ \ 2 2 / \ / \ 3 4 4 3 But the f原创 2017-04-04 09:57:13 · 320 阅读 · 0 评论 -
Leetcode-100. Same Tree
题目Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 比较两颗二叉树是否相等,必须在原创 2017-03-26 17:52:27 · 323 阅读 · 0 评论 -
Leetcode-94. Binary Tree Inorder Traversal
题目Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?原创 2017-04-03 22:23:57 · 243 阅读 · 0 评论 -
Leetcode-145. Binary Tree Postorder Traversal
题目Given a binary tree, return the postorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, return [3,2,1].Note: Recursive solution is trivial, could you do it iteratively?原创 2017-04-03 22:28:14 · 249 阅读 · 0 评论 -
Leetcode-102. Binary Tree Level Order Traversal
题目Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level).For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20原创 2017-04-04 08:40:49 · 307 阅读 · 0 评论 -
Leetcode-107. 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 level from leaf to root).For example: Given binary tree [3,9,20,null,null,15,7原创 2017-04-04 08:47:02 · 243 阅读 · 0 评论 -
Leetcode-199. Binary Tree Right Side View
题目Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example: Given the following binary tree, 1原创 2017-04-04 08:57:25 · 254 阅读 · 0 评论 -
Leetcode-226. Invert Binary Tree
题目Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 反转一颗了二叉树代码一、层次遍历TreeNode* invertTree(TreeNode* root) { if(原创 2017-04-04 09:10:42 · 234 阅读 · 0 评论 -
Leetcode-173. Binary Search Tree Iterator
题目Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and ha原创 2017-04-04 09:22:05 · 243 阅读 · 0 评论 -
Leetcode-103. Binary Tree Zigzag Level Order Traversal
题目Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).For example: Given binary tre原创 2017-04-04 09:28:09 · 302 阅读 · 0 评论 -
Leetcode--655. Print Binary Tree
题目Print a binary tree in an m*n 2D string array following these rules:The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number. The原创 2017-08-09 09:47:11 · 434 阅读 · 0 评论