码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
Tree Recovery(由先、中序列构建二叉树)
题目来源: http://poj.org/problem?id=2255 题目描述: Description Little Valentine liked playing with binary trees very much. Her favorite game was constructing ...
分类:其他好文   时间:2018-01-25 00:29:17    阅读次数:171
230. Kth Smallest Element in a BST
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 ...
分类:其他好文   时间:2018-01-24 22:11:50    阅读次数:118
98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only ...
分类:其他好文   时间:2018-01-24 19:56:13    阅读次数:164
[leetcode]114. Flatten Binary Tree to Linked List由二叉树构建链表
/* 先序遍历构建链表,重新构建树 */ LinkedList list = new LinkedList(); public void flatten(TreeNode root) { preOrder(root); TreeNode res = root; list.poll(); while ... ...
分类:其他好文   时间:2018-01-24 14:03:05    阅读次数:173
[leetcode]108. Convert Sorted Array to Binary Search Tree构建二叉搜索树
构建二叉搜索树 ...
分类:其他好文   时间:2018-01-24 11:05:06    阅读次数:203
[Leetcode] Unique Binary Search Trees II
Unique Binary Search Trees II 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/unique binary search trees ii/description/ Description Given an integer ...
分类:其他好文   时间:2018-01-23 23:20:29    阅读次数:189
129. 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 whic ...
分类:其他好文   时间:2018-01-23 22:12:05    阅读次数:204
96. Unique Binary Search Trees
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' ...
分类:其他好文   时间:2018-01-23 14:32:18    阅读次数:146
[LeetCode]501. Find Mode in Binary Search Tree二叉搜索树寻找众数
这次是二叉搜索树的遍历 感觉只要和二叉搜索树的题目,都要用到一个重要性质: 中序遍历二叉搜索树的结果是一个递增序列; 而且要注意,在递归遍历树的时候,有些参数如果是要随递归不断更新(也就是如果递归返回上层,参数也需要最新的),就要用全局变量,而不是传参,其实这就是全局变量的定义。 不过如果是保存每层 ...
分类:其他好文   时间:2018-01-22 17:37:12    阅读次数:139
117. Populating Next Right Pointers in Each Node II
Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution sti ...
分类:其他好文   时间:2018-01-22 13:08:01    阅读次数:118
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!