码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
leetcode 74. Search a 2D Matrix
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l...
分类:其他好文   时间:2015-02-25 23:42:55    阅读次数:133
LeetCode Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found ...
分类:其他好文   时间:2015-02-25 21:10:33    阅读次数:163
NYOJ 233 &&NYOJ 322 Sort(树状数组)
链接:click here 题意: 描述 You want to processe a sequence of n distinct integers by swapping two adjacent sequence elements until the sequence is sorted in ascending order. Then how many times it nee...
分类:编程语言   时间:2015-02-25 21:10:08    阅读次数:153
LeetCode 154. Find Minimum in Rotated Sorted Array II
二分搜索,和LeetCode 153. Find Minimum in Rotated Sorted Array相似。 只是在num[begin] == num[mid]时,需要binary_search(++ begin, end, num); 这时仅将begin移进一位,并没有进行二分查找。 所以如测试用例为 num = {1, 1, 1, 1, 1, ..., 1}等特殊情况时,最坏情况...
分类:其他好文   时间:2015-02-24 00:50:43    阅读次数:206
LeetCode 153. Find Minimum in Rotated Sorted Array
二分查找。 因为在旋转前的数组是排好序了的, 所以当num[begin] > num[mid]时,表示我们要搜寻的最小数字在num[begin, ..., mid]之间; 反之,num[begin] 例:考虑num = {5, 6, 7, 1, 2, 3, 4}, begin = 0, end = 6, mid = 3 num[begin] = 5 > num[m...
分类:其他好文   时间:2015-02-23 23:43:09    阅读次数:350
辛星浅析Redis中的有序集合
Redis中的有序集合也就是sorted-set,它和set很相似,都是字符串的集合,都不允许重复的成员出现在一个集合张。有序集合与集合的主要差别是有序集合中的每一个元素都有一个序号与其相连,这个序号即score,Redis通过这个序号来为集合中的成员进行从小到大的排列。需要特别说明的是,尽管有序集合的元素值是唯一的,但是该value对应的score却可以是多个。在有序集合中添加、删除、更新一个成...
分类:其他好文   时间:2015-02-23 19:02:41    阅读次数:244
PAT1089. Insert or Merge
According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, inserti...
分类:其他好文   时间:2015-02-22 15:47:40    阅读次数:163
leetcode 80. Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret...
分类:其他好文   时间:2015-02-22 15:46:43    阅读次数:121
leetcode 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:其他好文   时间:2015-02-21 17:42:24    阅读次数:124
leetcode 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given1->1->2, return1->2.Given1->1->2->3->3, retu...
分类:其他好文   时间:2015-02-21 11:58:06    阅读次数:115
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!