Question:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1...
分类:
其他好文 时间:
2015-07-14 13:01:50
阅读次数:
130
一、函数的声明
1.在C语言中,函数的定义顺序是有讲究的:默认情况下,只有后面定义的函数才可以调用前面定义过的函数
1 int sum(int a, int b) {
2 return a + b;
3 }
4
5 int main()
6 {
7 int c = sum(1, 4);
8 return 0;
9 }
第5行定义的main函数...
分类:
移动开发 时间:
2015-07-14 11:46:56
阅读次数:
146
Given a binary tree, return the inorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?二叉树的...
分类:
其他好文 时间:
2015-07-14 11:42:35
阅读次数:
94
Given a binary tree, return the preorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [1,2,3].Note: Recursive solution is trivial, could you do it iteratively?先序遍...
分类:
其他好文 时间:
2015-07-14 11:30:36
阅读次数:
133
Given an array of strings, return all groups of strings that are anagrams.
Note: All inputs will be in lower-case.
这道题是题目都没读懂,不知道Anagrams什么意思。Anagrams的意思是那些字符串的组成字符相同。比如说abc,那么abc这三个字符的所有排列都是Anagr...
分类:
其他好文 时间:
2015-07-14 10:08:44
阅读次数:
109
using System.Net.NetworkInformation;/// /// ping the specified ip/// /// ip address, "x.x.x.x"/// if connected, return true, otherwise return falsepri...
题目: 056 Merge Intervals这道题和 057 基本相似, 想法更加直接, 对start 进行排序,然后扫描一次并跟新返回的答案class Solution: # @param {Interval[]} intervals # @return {Interval[]} ...
分类:
其他好文 时间:
2015-07-14 08:42:19
阅读次数:
166
题意:求n个数的最小公倍数
分析:用方法:lcm(a,b,c)=lcm(a,lcm(b,c))。注意先除后乘防止整数溢出(小技巧)
代码:
#include
using namespace std;
int t,n,a;
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
cin>>t;
while(t--){...
分类:
其他好文 时间:
2015-07-14 06:14:22
阅读次数:
145
题目:130 Surrounded Regionsbfs搜索即可from Queue import Queueclass Solution: # @param {character[][]} board # @return {void} Do not return anything, m...
分类:
其他好文 时间:
2015-07-14 06:09:45
阅读次数:
127
题目:120 Triangle这道题纯dp, 但是有一个比一下代码优化的做法,就是从底部bottomu-up dp.class Solution: # @param triangle, a list of lists of integers # @return an integer ...
分类:
其他好文 时间:
2015-07-14 06:04:55
阅读次数:
114