Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-07-07 14:58:47
阅读次数:
175
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
分类:
其他好文 时间:
2014-07-07 14:48:39
阅读次数:
160
题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not poss...
分类:
其他好文 时间:
2014-07-07 10:57:23
阅读次数:
175
题目要求第n个丑数,所以对于中间结果不需要保存。
def Humble(index):
curHum = 1
M2 = 2; M3 = 3; M5 = 5
while index > 1:
curHum = min(min(M2, M3), M5)
while M2 <= curHum:
M2 *= 2
while M3 <= curHum:
M3 *= 3
w...
分类:
其他好文 时间:
2014-07-03 17:29:40
阅读次数:
214
书里面关于分类的判断有些麻烦,通过某一位为0为1来对数组元素进行分类。假如第3位为1,那么也就是元素x & 8 等于或不等于0,所以没必要非的用第几位去判断。
def once(array):
reOR = 0
for x in array:
reOR ^= x
bit1 = firstBit1(reOR)
first = 0
second = 0
for x in a...
分类:
其他好文 时间:
2014-07-03 13:54:06
阅读次数:
182
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
分类:
其他好文 时间:
2014-07-02 00:24:04
阅读次数:
284
PalindromesA regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string"ABCDEDCBA"is a palindr...
分类:
其他好文 时间:
2014-07-01 18:52:11
阅读次数:
460
Combinations:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ ...
分类:
其他好文 时间:
2014-07-01 12:58:20
阅读次数:
212
题目
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 it a...
分类:
其他好文 时间:
2014-07-01 09:11:07
阅读次数:
206
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2014-06-30 21:36:50
阅读次数:
292