Java连接redis的使用演示样例 Redis是开源的key-value存储工具,redis通经常使用来存储结构化的数据,由于redis的key能够包括String、hash、listset和sorted list。 Redisserver眼下最稳定的版本号是2.8.9,能够到官网http://r...
分类:
编程语言 时间:
2014-06-25 22:19:07
阅读次数:
355
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number...
分类:
其他好文 时间:
2014-06-25 22:07:58
阅读次数:
330
Divide two integers without using multiplication, division and mod operator.
思路:1.先将被除数和除数转化为long的非负数,注意一定要为long,因为Integer.MIN_VALUE的绝对值超出了Integer的范围。
2.常理:任何正整数num都可以表示为num=2^a+2^b+2^c+.....
分类:
其他好文 时间:
2014-06-25 19:46:17
阅读次数:
246
Peterson's algorithm (AKA Peterson's solution) is a concurrent
programming algorithm for mutual
exclusion that allows two processes to share a single-use resource without conflict, using only shar...
分类:
编程语言 时间:
2014-06-25 19:38:19
阅读次数:
748
题目:Tuhao and his two small partners participated in the tournament.But in the end, they lost the chance to finish a mathematical problem.After the com...
分类:
其他好文 时间:
2014-06-25 18:07:35
阅读次数:
333
【题目】
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
Note:
You may not engage in multiple transactions at the same time (i...
分类:
其他好文 时间:
2014-06-24 23:28:43
阅读次数:
223
题目
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return...
分类:
其他好文 时间:
2014-06-24 21:46:24
阅读次数:
249
排序算法有不少,当然,一般的语言中都提供某个排序函数,比如Python中,对list进行排序,可以使用sorted(或者list.sort()),关于这方面的使用,在我的github代码库algorithm中有几个举例,有兴趣的看官可以去那里看看(顺便告知,我在Github中的账号是qiwsir,欢迎follow me)。但是,在某些情况下,语言中提供的排序方法或许不适合,必须选择某种排序算法。
...
分类:
其他好文 时间:
2014-06-24 18:33:33
阅读次数:
205
题目
Given n non-negative integers a1, a2,
..., an, where each represents a point at coordinate (i, ai). n vertical
lines are drawn such that the two endpoints of line i is at (i, ai) and (...
分类:
其他好文 时间:
2014-06-24 16:00:49
阅读次数:
220
二叉查找树(Binary Search Tree),也称有序二叉树(ordered binary tree),排序二叉树(sorted binary tree),是指一棵空树或者具有下列性质的二叉树:若任意节点的左子树不空,则左子树上所有结点的值均小于它的根结点的值;任意节点的右子树不空,则右子树上...
分类:
其他好文 时间:
2014-06-24 12:21:17
阅读次数:
257