今天用python自带的sorted对一个列表进行排序, 在这里总结一下只要是可迭代对象都可以用sorted 。sorted(itrearble, cmp=None, key=None, reverse=False)=号后面是默认值 默认是升序排序的, 如果想让结果降序排列,用reverse=Tru...
分类:
编程语言 时间:
2014-07-26 14:49:40
阅读次数:
284
E -Power StringsTime Limit:3000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusPracticePOJ 2406DescriptionGiven two strings a and b we ...
分类:
其他好文 时间:
2014-07-26 14:10:16
阅读次数:
201
Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 #includeintnext[10005];ints[1000005],p[10005];intn,m;void...
分类:
其他好文 时间:
2014-07-26 13:46:34
阅读次数:
297
题目:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题解:Merge k sorted linked list就是merge 2 sorted li....
分类:
编程语言 时间:
2014-07-26 05:44:37
阅读次数:
304
Painting Storages
Time Limit: 2 Seconds Memory Limit: 65536 KB
There is a straight highway with N storages alongside it labeled by 1,2,3,...,N. Bob asks you to paint all storages with two...
分类:
其他好文 时间:
2014-07-26 02:48:17
阅读次数:
178
B. Power StringsTime Limit: 3000msMemory Limit: 65536KB64-bit integer IO format:%lld Java class name:MainGiven two strings a and b we define a*b to be...
分类:
其他好文 时间:
2014-07-26 01:25:26
阅读次数:
300
题目:如果采取暴力搜索,复杂度为O(n2),会超时解法1:构建Node类,存储输入的数据和它们的下标。用sort按升序排序(其中lambda可以写成一个返回值为bool类型的函数)。设置i和j,分别指向容器的头和尾。如果和大于target,尾向前移,如果和小于target,头向后移。直至找出和等于t...
分类:
其他好文 时间:
2014-07-26 00:31:46
阅读次数:
223
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-26 00:23:26
阅读次数:
242
Just Pour the WaterTime Limit: 2 Seconds Memory Limit: 65536 KBShirly is a very clever girl. Now she has two containers (A and B), each with some wat....
分类:
其他好文 时间:
2014-07-25 18:58:22
阅读次数:
374
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-25 03:15:41
阅读次数:
176