题目:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".要求:1)首尾有空格的时候,反转后的string要将空...
分类:
其他好文 时间:
2014-07-16 19:29:54
阅读次数:
234
描述: Given two integersnandk, return all possible combinations ofknumbers out of 1 ...n.For example,Ifn= 4 andk= 2, a solution is:[ [2,4], [3,4], [2...
分类:
其他好文 时间:
2014-07-16 19:29:31
阅读次数:
166
FRIENDS题意:找出最大的朋友圈#include #define N 30005int fa[N], ans[N];int find(int x){ return fa[x] == x ? x : fa[x] = find(fa[x]);}int main(int argc, char *...
分类:
其他好文 时间:
2014-07-15 08:48:35
阅读次数:
214
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
lambda表达式返回一个函数对象例子:func = lambda x,y:x+yfunc相当于下面这个函数def func(x,y): return x+y 注意def是语句而lambda是表达式下面这种情况下就只能用lambda而不能用def[(lambda x:x*x)(x) for x...
分类:
编程语言 时间:
2014-07-15 08:42:41
阅读次数:
341
filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的类型)返回:>>> def f(x): return x % 2 != 0 an...
分类:
编程语言 时间:
2014-07-15 08:41:24
阅读次数:
292
3Sum ClosestGiven an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three int...
分类:
其他好文 时间:
2014-07-14 15:23:22
阅读次数:
171
1、使用function类//myFunction.jsvar CMyFunc=function(){//类的公共方法,供外部调用this.Func1=function(){var i=0;return i;}this.Func2=function(){_privateFunc();}//类中的私有...
分类:
编程语言 时间:
2014-07-13 19:06:40
阅读次数:
242
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
/**
* Definition for bi...
分类:
其他好文 时间:
2014-07-13 18:46:25
阅读次数:
249
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 as a link...
分类:
其他好文 时间:
2014-07-13 18:20:52
阅读次数:
202