Summary RangesGiven a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5",...
分类:
其他好文 时间:
2015-07-08 22:16:05
阅读次数:
120
Given an integer, write a function to determine if it is a power of two.method:1. recursive:if x % 2 != 0, return false;if x == 0, return false;if x =...
分类:
其他好文 时间:
2015-07-08 20:48:12
阅读次数:
97
Majority Element IIGiven an integer array of sizen, find all elements that appear more than? n/3 ?times. The algorithm should run in linear time and i...
分类:
其他好文 时间:
2015-07-08 20:28:29
阅读次数:
103
1 enum status{VALID = 0, INVALID}; 2 int g_status; 3 4 long long SubStrToInt(const char* str, bool minus) 5 { 6 long long num = 0; 7 int fl...
分类:
其他好文 时间:
2015-07-08 18:12:09
阅读次数:
105
数据库死锁的解决办法近日在博客网站上,回复别人的数据库死锁避免问题,之前也曾经几次答复过同样的内容,觉得很有必要汇聚成一个博客文章,方便大家。这里的办法,对所有的数据库都适用。这个解决办法步骤如下:1. 每个表中加 updated_count (integer) 字段2. 新增一行数据,update...
分类:
数据库 时间:
2015-07-08 16:17:12
阅读次数:
169
这道题比较a[start] 和 a[half]的值就可以判断 该序列的头在左半部分 还是右半部分,这样就可以利用二分查找了class Solution: # @param A, a list of integers # @param target, an integer to be se...
分类:
其他好文 时间:
2015-07-08 14:29:10
阅读次数:
89
二分法, 最后注意一下输出的时候要和 nums[left]比较一下来决定输出多少class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer} def search...
分类:
其他好文 时间:
2015-07-08 14:25:09
阅读次数:
94
在 033Search in Rotated Sorted Array 稍作改进, 但是最坏情况下 复杂度为O(n)class Solution: # @param A, a list of integers # @param target, an integer to be searc...
分类:
其他好文 时间:
2015-07-08 14:21:27
阅读次数:
132
这道题县排序 然后设定好第一位,后面两位夹逼搜索就好, 但是因为数字会出现重复,导致得出的3元祖也有可能重复,一开始我的办法是采用set来避免多次加入同样的三元组,运行时间为 344msclass Solution: # @param {integer[]} nums # @return...
分类:
其他好文 时间:
2015-07-08 07:11:23
阅读次数:
116
这道题与 015 3 SUM 基本思路一样 都是夹逼思想 复杂度 O(n*n)class Solution: # @param {integer[]} nums # @param {integer} target # @return {integer} def threeSu...
分类:
其他好文 时间:
2015-07-08 07:09:51
阅读次数:
101