码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
LeetCode83——Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. 难度系数: 容易 实现 ListN...
分类:其他好文   时间:2015-02-11 16:44:16    阅读次数:117
(26)Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for...
分类:其他好文   时间:2015-02-11 16:19:05    阅读次数:117
[LeetCode]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. Example Tags Expand  Recursion Linked List 解题思路: 思路一:平衡树调整。第一步建立一个单向树...
分类:其他好文   时间:2015-02-11 14:47:17    阅读次数:139
【LeetCode从零单排】No21.MergeTwoSortedLists
题目      这道题是链表的简单应用,将两个有序链表合成一个有序链表。       思路是:表一,表二各取两个对象,分别指向current和next,进行交叉比较排序。Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nod...
分类:其他好文   时间:2015-02-11 12:48:27    阅读次数:148
[转]An STL compliant sorted vector-源码示例
原文地址:http://www.codeproject.com/Articles/3217/An-STL-compliant-sorted-vector 最近在看sorted vectored的一些东西,自己封装了一个sorted vector类型,后来找到了codeproject上的一...
分类:其他好文   时间:2015-02-11 12:35:13    阅读次数:158
封装的一个sorted_vector示例,实现了stl::set的一部分接口
STL set能保证最坏情况下的查找和插入效率,logN。但是维护红黑树开销较大。set内的元素按照一定的逻辑顺序组织,查找、插入等操作的结果都和排序规则有关。 适合STL set的情况为: 1、集合很大,以至于O(N)远大于O(longN)。2、查找和插入的次数一样多,且需要考虑插入的效...
分类:其他好文   时间:2015-02-11 10:52:07    阅读次数:153
153.Find Minimum in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 mightbecome 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicate exists in the array...
分类:其他好文   时间:2015-02-11 09:27:00    阅读次数:166
LeetCode Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题意:将k个已经排好序的链表合并成一个 思路:用到优先队列比较简单。 /** * Definition for singly-linked list. * struct ListNod...
分类:其他好文   时间:2015-02-10 16:47:11    阅读次数:124
Find Minimum in Rotated Sorted Array II
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. The array may contain duplicates. 解...
分类:其他好文   时间:2015-02-10 15:22:51    阅读次数:195
LeetCode Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 题意:将两个有序的链表合并成一个链表 思路:每次比较链表头就行了,把比较小的插入新的链表中 /** ...
分类:其他好文   时间:2015-02-10 15:19:37    阅读次数:132
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!