题目:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function...
分类:
其他好文 时间:
2014-07-07 00:14:37
阅读次数:
186
题目: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).You are given a target valu...
分类:
其他好文 时间:
2014-07-06 23:34:53
阅读次数:
273
Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol...
分类:
其他好文 时间:
2014-07-06 19:31:04
阅读次数:
181
Divide two integers without using multiplication, division and mod operator.不用乘、除、求余操作,返回两整数相除的结果,结果也是整数。假设除数是2,相除的商就是被除数二进制表示向右移动一位。假设被除数是a,除数是b,因为不知...
分类:
其他好文 时间:
2014-07-05 20:37:18
阅读次数:
193
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 ord...
分类:
其他好文 时间:
2014-07-05 19:10:48
阅读次数:
219
The gray code is a binary numeral system where two successive values differ in only one bit.
Given a non-negative integer n representing the total number of bits in the code, print the sequence of...
分类:
其他好文 时间:
2014-07-04 07:35:58
阅读次数:
215
def IsContinuous(seq, num = 5):
zeros = 0; d = 0
seq = sorted(seq)
for i in range(num - 1):
if seq[i] == 0:
zeros += 1
continue
if seq[i] == seq[i + 1]:
return False
d += seq[i + 1]...
分类:
其他好文 时间:
2014-07-04 07:11:20
阅读次数:
171
What is the Median?
The Problem
Median plays an important role in the world of statistics. By definition, it is a value which divides an array into two equal parts. In this problem you are ...
分类:
其他好文 时间:
2014-07-03 17:43:53
阅读次数:
250
[LeetCode]Remove Duplicates from Sorted List...
分类:
其他好文 时间:
2014-07-03 16:00:08
阅读次数:
202