摘要: 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 阅读全文
posted @ 2017-10-22 21:58 daniel456 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2017-10-22 21:53 daniel456 阅读(117) 评论(0) 推荐(0) 编辑
摘要: The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou 阅读全文
posted @ 2017-10-22 21:41 daniel456 阅读(115) 评论(0) 推荐(0) 编辑
摘要: Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or 阅读全文
posted @ 2017-10-22 21:36 daniel456 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values 阅读全文
posted @ 2017-10-22 21:28 daniel456 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: 阅读全文
posted @ 2017-10-22 21:25 daniel456 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 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 whic 阅读全文
posted @ 2017-10-22 21:23 daniel456 阅读(96) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the root node of any oneof them. Two 阅读全文
posted @ 2017-10-22 21:20 daniel456 阅读(406) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the roo 阅读全文
posted @ 2017-10-22 17:33 daniel456 阅读(496) 评论(0) 推荐(0) 编辑
摘要: 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 symmet 阅读全文
posted @ 2017-10-22 17:20 daniel456 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might 阅读全文
posted @ 2017-10-22 17:18 daniel456 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E 阅读全文
posted @ 2017-10-22 17:08 daniel456 阅读(118) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: 阅读全文
posted @ 2017-10-22 17:05 daniel456 阅读(105) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt 阅读全文
posted @ 2017-10-22 17:03 daniel456 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2017-10-22 16:56 daniel456 阅读(119) 评论(0) 推荐(0) 编辑
摘要: nvert a binary tree. to 方法二:BfS 阅读全文
posted @ 2017-10-22 16:52 daniel456 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. 阅读全文
posted @ 2017-10-22 10:13 daniel456 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 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 n 阅读全文
posted @ 2017-10-22 10:10 daniel456 阅读(84) 评论(0) 推荐(0) 编辑