To add up all the numbers in a list, you can use a loop like this: Total is initialized to 0. Each time through the loop, x gets one element...
分类:
其他好文 时间:
2014-07-16 19:29:14
阅读次数:
234
题目Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which r...
分类:
其他好文 时间:
2014-07-15 23:21:33
阅读次数:
218
Two SumGiven 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...
分类:
其他好文 时间:
2014-07-15 08:45:17
阅读次数:
236
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence
...
分类:
其他好文 时间:
2014-07-14 14:03:02
阅读次数:
206
Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thes...
分类:
其他好文 时间:
2014-07-14 10:43:07
阅读次数:
222
Combination Sum IIGiven a collection of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sum...
分类:
其他好文 时间:
2014-07-14 10:42:22
阅读次数:
192
上一篇 说了些堆的建立及其相关操作,这里看下用堆来解决数据量较大的时候,查找最小的k个数的情况。这里会用到上一篇中的函数。
我们先生存1千万个随机数,写到文件中:
import random
def randData():
with open('randint.txt', 'w') as fd:
for i in range(1, 10000000):
fd.write('%...
分类:
其他好文 时间:
2014-07-13 18:51:05
阅读次数:
261
poj1338 Ugly Numbers(丑数模拟)...
分类:
其他好文 时间:
2014-07-13 18:42:24
阅读次数:
232
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
Description
Find and list all four-digit numbers in decimal notation that have the property ...
分类:
其他好文 时间:
2014-07-13 18:17:24
阅读次数:
198