注意:return的位置。。。从这几个例子中可以看到,如果try之前没有有条件的return,则try..catch..finally语句块中的语句都是顺序执行(如果try中或者catch中有return语句,那么先执行该return,然后执行finally, 如果finally中也有return,...
分类:
编程语言 时间:
2014-07-01 12:21:28
阅读次数:
211
题目
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Follow up:
Can you solve it without using extra space?
方法
public ListNode de...
分类:
其他好文 时间:
2014-07-01 11:30:58
阅读次数:
200
#include
int main()
{
int i = 5, j = 4;
printf("%0*d\n", i, j);
printf("%-10d\n", j);
return 0;
}
运行结果:
00004
4...
分类:
其他好文 时间:
2014-07-01 11:23:15
阅读次数:
133
题目
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 strings, return all groups of strings that are anagrams.
Note: All inputs will be in lower-case.
回文字符串是指: 两个字符串的字符个数完全相同,这两个字符串是Anagrams。因此Anagrams至少指俩字符串。找出字符集合中的Anagrams组。...
分类:
其他好文 时间:
2014-07-01 08:42:11
阅读次数:
250
#include //100元划分
int a[] ={1,10,20,50,100};
int q(int n,int m)//n为100元,m为数组的下标
{
if(n<1||a[m]<1) return 0;
if(n==1||a[m]==1) return 1;
if(n<a[m]) return q(n,m-1);
if(n==a[m]) return...
分类:
其他好文 时间:
2014-07-01 08:31:19
阅读次数:
242
var gcd = function (n1,n2){ //最大公约数
if(n1 == n2 ){return n1;}
var bigger = 0;
var smaller = 0;
if(n1 > n2){bigger = n1;smaller = n2;}
else {bigger = n2;smaller = n1;}
for(var j = 1; j <= smaller ;...
分类:
其他好文 时间:
2014-07-01 08:30:43
阅读次数:
190
题目
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
方法
publi...
分类:
其他好文 时间:
2014-07-01 07:49:33
阅读次数:
186
题目
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].
Note: Recu...
分类:
其他好文 时间:
2014-07-01 07:06:56
阅读次数:
177
题目
Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: Rec...
分类:
其他好文 时间:
2014-07-01 07:06:11
阅读次数:
214