Leetcode_tree
佛系城
这个作者很懒,什么都没留下…
展开
-
617. Merge Two Binary Trees
题目来源【Leetcode】 Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them in原创 2017-07-15 08:55:32 · 285 阅读 · 0 评论 -
144. Binary Tree Preorder Traversal
题目描述【Leetcode】 Given a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]原创 2017-07-18 13:21:01 · 141 阅读 · 0 评论 -
94. Binary Tree Inorder Traversal
题目描述【Leetcode】 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 tri原创 2017-07-18 13:03:07 · 132 阅读 · 0 评论 -
623. Add One Row to Tree
题目描述【Leetcode】 Given the root of a binary tree, then value v and depth d, you need to add a row of nodes with value v at the given depth d. The root node is at depth 1. The adding rule is: given原创 2017-07-18 12:43:22 · 171 阅读 · 0 评论 -
235. Lowest Common Ancestor of a Binary Search Tree
题目来源【Leetcode】 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is d原创 2017-07-18 09:48:20 · 151 阅读 · 0 评论 -
437. Path Sum III
题目描述【Leetcode】 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 not need to start or end at the ro原创 2017-07-17 15:08:38 · 164 阅读 · 0 评论 -
107. Binary Tree Level Order Traversal II
题目描述【Leetcode】 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原创 2017-07-17 14:09:07 · 218 阅读 · 0 评论 -
572. Subtree of Another Tree
题目描述【Leetcode】 Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and原创 2017-07-17 13:47:53 · 172 阅读 · 0 评论 -
108. Convert Sorted Array to Binary Search Tree
题目描述【Leetcode】 Given an array where elements are sorted in ascending order, convert it to a height balanced BST.这道题就是把一个排好序的数组变成一个height balanced BST.那么就需要用二分法不断的进行节点的选择保证每次的节点选择都小于右子树且大于左子树。代码如下:/*原创 2017-07-16 09:36:55 · 140 阅读 · 0 评论 -
543. Diameter of Binary Tree
题目描述【Leetcode】 Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This p原创 2017-07-16 09:13:54 · 165 阅读 · 0 评论 -
404. Sum of Left Leaves
题目来源【Leetcode】 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key原创 2017-07-15 18:15:19 · 127 阅读 · 0 评论 -
563. Binary Tree Tilt
题目来源【Leetcode】 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key原创 2017-07-15 17:54:13 · 148 阅读 · 0 评论 -
226. Invert Binary Tree
题目来源【Leetcode】 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key原创 2017-07-15 17:17:20 · 175 阅读 · 0 评论 -
538. Convert BST to Greater Tree
题目来源【Leetcode】 Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key原创 2017-07-15 17:02:32 · 196 阅读 · 0 评论 -
230. Kth Smallest Element in a BST
题目描述【Leetcode】 Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ? k ? BST’s total elements.找出二叉搜索树的原创 2017-07-18 13:31:16 · 198 阅读 · 0 评论