![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
Dream_WHui
光棍一个
展开
-
LeetCode | 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 diffe原创 2015-04-06 13:13:27 · 473 阅读 · 0 评论 -
LeetCode | 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 6The flattened tree should look like: 1原创 2015-04-07 15:32:26 · 417 阅读 · 0 评论 -
LeetCode | Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路:本题给出二叉树的先序遍历和中序遍历,然后构建出这颗二叉树。分析:先序遍历的顺序是根结点、左子树、右子原创 2015-04-07 15:46:26 · 603 阅读 · 0 评论 -
LeetCode | 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()原创 2015-04-06 16:36:13 · 418 阅读 · 0 评论 -
LeetCode | 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,#,#,15,7}, 3 / \ 9 20原创 2015-04-06 15:01:06 · 439 阅读 · 0 评论 -
LeetCode | 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原创 2015-04-06 16:24:36 · 388 阅读 · 0 评论 -
LeetCode | Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota原创 2015-04-06 16:16:49 · 469 阅读 · 1 评论 -
LeetCode | 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 / \原创 2015-04-06 16:02:32 · 478 阅读 · 0 评论 -
LeetCode | 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原创 2015-04-06 15:55:16 · 379 阅读 · 0 评论 -
LeetCode | 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.思路:如果两颗二叉树原创 2015-04-06 13:44:30 · 470 阅读 · 0 评论 -
Leetcode | Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f原创 2015-04-06 13:28:01 · 516 阅读 · 0 评论 -
LeetCode | 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,#,#,15,7},原创 2015-04-06 15:50:57 · 439 阅读 · 0 评论 -
LeetCode | 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.思路:如果根结点为空,则为0;如果根结点不为空,且左右子树都存在原创 2015-04-06 14:10:47 · 509 阅读 · 0 评论 -
LeetCode | 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.思路:如果根结点为空,那么深度为0,否则就计算其左子树和右子树的深度原创 2015-04-06 14:03:37 · 520 阅读 · 0 评论 -
LeetCode | 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 \ 2 / 3return [1,2,3].思路:本题为二叉树的先序遍历,有两种方法。1原创 2015-04-06 12:49:40 · 439 阅读 · 0 评论 -
LeetCode | Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without u原创 2015-06-19 13:10:14 · 517 阅读 · 1 评论