随笔分类 -  leetcode_tree

摘要: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 阅读全文
posted @ 2017-10-21 22:50 daniel456 阅读(92) 评论(0) 推荐(0) 编辑
摘要: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 longestpath betwee 阅读全文
posted @ 2017-10-21 22:37 daniel456 阅读(80) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-10-21 22:33 daniel456 阅读(83) 评论(0) 推荐(0) 编辑
摘要: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. F 阅读全文
posted @ 2017-10-21 22:29 daniel456 阅读(117) 评论(0) 推荐(0) 编辑
摘要: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 l 阅读全文
posted @ 2017-10-21 22:26 daniel456 阅读(133) 评论(0) 推荐(0) 编辑
摘要: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 dept 阅读全文
posted @ 2017-10-21 22:18 daniel456 阅读(136) 评论(0) 推荐(0) 编辑
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题目含义:给定了一个升序的数组,转换成一个平衡二叉树 阅读全文
posted @ 2017-10-21 17:46 daniel456 阅读(116) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2017-10-21 17:43 daniel456 阅读(104) 评论(0) 推荐(0) 编辑
摘要: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 l 阅读全文
posted @ 2017-10-21 17:37 daniel456 阅读(129) 评论(0) 推荐(0) 编辑
摘要: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 a 阅读全文
posted @ 2017-10-21 17:14 daniel456 阅读(76) 评论(0) 推荐(0) 编辑
摘要: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 t 阅读全文
posted @ 2017-10-21 17:13 daniel456 阅读(119) 评论(0) 推荐(0) 编辑
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST' 阅读全文
posted @ 2017-10-19 10:55 daniel456 阅读(108) 评论(0) 推荐(0) 编辑
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
posted @ 2017-10-19 10:44 daniel456 阅读(94) 评论(0) 推荐(0) 编辑
摘要:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be rep 阅读全文
posted @ 2017-10-17 15:59 daniel456 阅读(139) 评论(0) 推荐(0) 编辑
摘要:Given inorder and postorder traversal of a tree, construct the binary tree. 题目:给定一个树的中序排列和后续排列数组,重新绘制出该树 思路:由于后序的顺序的最后一个肯定是根,所以原二叉树的根节点可以知道,题目中给了一个很关键 阅读全文
posted @ 2017-10-16 15:44 daniel456 阅读(179) 评论(0) 推荐(0) 编辑
摘要:Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 给定一个二叉树的先序遍历和 阅读全文
posted @ 2017-10-16 15:20 daniel456 阅读(157) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示