题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to ....
分类:
编程语言 时间:
2014-08-03 05:24:06
阅读次数:
304
对于集合的遍历首选方法是for-each
for(Element e :c){
doSomething(e);
}
这是1.5版本之后的做法;java1.5之前使用的是Iterator迭代器。
为了弄清楚为啥比普通的for循环或者whlie循环好,请看一下代码
Iterator i=c.iterator();
while(i.hasNext()){...
分类:
其他好文 时间:
2014-08-02 23:26:54
阅读次数:
356
Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?...
分类:
其他好文 时间:
2014-08-02 12:53:53
阅读次数:
289
Watson gives an array A1,A2...AN to Sherlock. Then he asks him to find if there exists an element in the array, such that, the sum of elements on its ...
分类:
其他好文 时间:
2014-08-02 12:36:13
阅读次数:
185
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2112The Company Dynamic Rankings has developed a new kind of computer that is no lon...
分类:
其他好文 时间:
2014-08-02 01:37:22
阅读次数:
582
问题:删除数组中和elem相等的元素,并且返回新数组大小。英语不好。。。读错题了。。class Solution {public: int removeElement(int A[], int n, int elem) { int i,j; for(int i=0;...
分类:
其他好文 时间:
2014-08-01 23:03:22
阅读次数:
223
Greedy, Greedy, Greedy.. It is all about maximum interval update.One trick is, we start looping over each element from the one nearest to end to farth...
分类:
其他好文 时间:
2014-08-01 13:32:21
阅读次数:
283
Your browser does not support the canvas element.
分类:
Web程序 时间:
2014-08-01 13:15:21
阅读次数:
231
Single NumberGiven an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runti...
分类:
其他好文 时间:
2014-08-01 04:44:31
阅读次数:
189
见摘要、见代码注释,其他话不多说: DTD文档: <?xml?version="1.0"?encoding="UTF-8"?>
<!ELEMENT?SwordLibrary?(Sword*)>
<!ELEMENT?Sword?(SwordName,Price,Attack)>
<!ELEMENT?SwordName?(#PCDATA)...
分类:
编程语言 时间:
2014-08-01 00:18:51
阅读次数:
359