码迷,mamicode.com
首页 >  
搜索关键字:sorted    ( 5925个结果
leetcode Remove Duplicates from Sorted List
给定一个链表,去除重复的值,每个数字只出现一次,例如Given1->1->2, return1->2.Given1->1->2->3->3, return1->2->3.思路:用pre记录合法链表的最后一个,now为第二个节点一直往后走,如果now的值不等于pre那么更新pre为now,now继续往...
分类:其他好文   时间:2014-11-18 23:44:34    阅读次数:307
[Leetcode] 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-...
分类:其他好文   时间:2014-11-18 06:58:19    阅读次数:145
leetcode[82] Remove Duplicates from Sorted List II
给定一个有序链表,删除相同值的节点。例如Given1->2->3->3->4->4->5, return1->2->5.Given1->1->1->2->3, return2->3.我是新建一个ans链表,来存链表中distinct的值。不知道这样符合要求不。判断当前的值不等于前面一个也不等于后面一...
分类:其他好文   时间:2014-11-18 01:38:12    阅读次数:134
LeetCode Find Minimum In Rotated Sorted Array
#include #include #include using namespace std;// 4 5 1 2// 1 2class Solution {public: int findMin(vector &num) { int len = num.size(); ...
分类:其他好文   时间:2014-11-18 01:35:47    阅读次数:115
leetcode[81] Search in Rotated Sorted Array II
此题是Search in Rotated Sorted Array的加强版,将一个有序数组往右移动若干位。这里的有序数组允许有重复数字。如果没有重复数字,那么复杂度是O(logn),用二分查找,根据中间值和左右两边的大小,以及和target的大小,来判断缩小一半查找。但是出现重复数字之后,如果中间值...
分类:其他好文   时间:2014-11-18 00:20:39    阅读次数:213
Leetcode: 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-...
分类:其他好文   时间:2014-11-18 00:18:35    阅读次数:182
redis-排序
Redis排序本篇文章介绍下redis排序命令.redis支持对list,set和sorted set元素的排序。排序命令是sort 完整的命令格式如下:SORT key [BYpattern] [LIMIT start count] [GET pattern] [ASC|DESC] [ALPHA]...
分类:编程语言   时间:2014-11-18 00:11:34    阅读次数:240
leetcode[80] Remove Duplicates from Sorted Array II
给定一个排好序的数组,要求里面数字重复的次数不超过2,并且记录在原数组的前头,返回剩余长度。例如给定:A = [1,1,1,2,2,3] 返回 5,并且A = [1,1,2,2,3]思路:用till记录满足条件的下一个位置,以便下一次填入用repeat记录重复的次数,超过2则不理,否则往till里....
分类:其他好文   时间:2014-11-18 00:05:44    阅读次数:228
[Leetcode] Merge k Sorted Lists
Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution 1:PriorityQueue: 1 /** 2 * Definition for si....
分类:其他好文   时间:2014-11-17 08:04:09    阅读次数:176
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 7might become4 5 6 7 0 1 2).Find the minimum element.You m...
分类:其他好文   时间:2014-11-17 00:21:07    阅读次数:213
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!