The problem:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were in...
分类:
其他好文 时间:
2015-01-18 07:06:14
阅读次数:
293
The question:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?S...
分类:
其他好文 时间:
2015-01-18 07:06:07
阅读次数:
338
上一篇已经讲了一部分有序集合类型的命令了
http://blog.csdn.net/wtyvhreal/article/details/42804571
三、命令拾遗
1.获得集合中元素的数量
zcard key
2.获得指定分数范围内的元素个数
zcount key min max
3.删除一个或者多个元素
zrem key member
返回值是成功删除的元素...
分类:
其他好文 时间:
2015-01-17 18:11:44
阅读次数:
209
题目 :
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.
我的解法:
(1)算法思想:...
分类:
其他好文 时间:
2015-01-17 18:03:36
阅读次数:
190
一、介绍
sorted set为集合中的每个元素都关联了一个分数,所以可以获得分数最高或者最低的前N个元素,获得指定分数范围内的元素等与分数有关的操作。虽然集合中每个元素都是不同的,但是他们的分数却可以相同。
有序集合类型与列表类型有些相似
(1)二者都是有序的
(2)二者都可以获得某一个范围的元素。
但是二者有很大的区别
(1)列表通过链表实现,获取两端数据速度快,访问中间数...
分类:
其他好文 时间:
2015-01-17 13:56:33
阅读次数:
145
题目: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 ...
分类:
编程语言 时间:
2015-01-16 23:36:59
阅读次数:
686
题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo...
分类:
编程语言 时间:
2015-01-16 22:14:33
阅读次数:
223
一、Redis的简介:
NoSql 及No Only SQL,是高并发,超大数据存在,不同于关系型数据库。拥有:非关系型,分布式,开源的,可水平扩展。
Redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的...
分类:
数据库 时间:
2015-01-16 20:56:21
阅读次数:
333
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 ...
分类:
其他好文 时间:
2015-01-16 18:48:24
阅读次数:
139
题目:Given an array where elements are sorted in ascending order, convert it to a height balanced
BST.
思路:给出一个排序的数组,如何构造一个平衡二叉查找树?平衡二叉查找树要求任一结点的左右子树的高度差不能超过一,也叫做高度平衡树。如果让我们从一个排序数组中选取一个元素做树的根,我们会选择哪一个...
分类:
编程语言 时间:
2015-01-16 16:51:25
阅读次数:
237