码迷,mamicode.com
首页 >  
搜索关键字:elements    ( 4737个结果
LintCode-Implement Iterator of Binary Search Tree
Design an iterator over a binary search tree with the following properties:Elements are visited in ascending order (i.e. an inorder traversal)next() a...
分类:其他好文   时间:2014-12-31 07:34:29    阅读次数:168
[Leetcode] Maximum Gap
Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ...
分类:其他好文   时间:2014-12-31 06:21:14    阅读次数:281
【leetcode】Longest Consecutive Sequence
Longest Consecutive SequenceGiven an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4...
分类:其他好文   时间:2014-12-30 21:53:34    阅读次数:189
Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 将增序数组转换为左右均衡的二叉查找树 根据查找树的性质 左子树所有节点小于根节点值 右边都大于根节点值 子树也遵循此性质 所以只要取出增序数组的中间值作为根节点 再将左右子数组进行递归 代码如下: p...
分类:其他好文   时间:2014-12-30 17:18:32    阅读次数:168
Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 将增序链表转换为均衡的二叉查找树 与数组转换相同 找到链表的中间结点 作为树的根节点进行赋值  再将链表以中间节点为界 分为左右子链表 进行递归赋值 代码如下: publi...
分类:其他好文   时间:2014-12-30 17:11:39    阅读次数:149
[leedcode] Maximum Gap
题目:(Sort)Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space....
分类:其他好文   时间:2014-12-30 01:45:54    阅读次数:195
LeetCode Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:根据递增序列,求平衡二叉查找树,根据平衡二叉查找树的性质,其左右都是二叉查找树,用递归可以比较轻...
分类:其他好文   时间:2014-12-29 22:55:25    阅读次数:297
【leetcode】Subsets
SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must...
分类:其他好文   时间:2014-12-29 22:52:49    阅读次数:198
【leetcode】Subsets II
Subsets IIGiven a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descend...
分类:其他好文   时间:2014-12-29 22:48:25    阅读次数:240
[LeetCode]109.Convert Sorted List to Binary Search Tree
【题目】 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 【分析】 无 【代码】 在下面超时的代码上进行改进:把链表先转换为vector再进行操作。 [LeetCode]108.Convert Sorted Ar...
分类:其他好文   时间:2014-12-29 12:14:29    阅读次数:124
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!