这两题都比较简单,第一题输出杨辉三角,第二题输出特定的某一行,第二题要求空间复杂度为O(k)
代码如下:
Pascal's Triangle:
public List> generate(int numRows) {//direct simulate
List> rs = new LinkedList>();
if(numRows == 0)retur...
分类:
其他好文 时间:
2015-04-15 14:55:55
阅读次数:
135
题目传送门 1 /* 2 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 3 注意:a==0时要特判:) 4 */ 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 ...
分类:
其他好文 时间:
2015-04-13 22:48:12
阅读次数:
135
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2015-04-13 14:34:42
阅读次数:
100
Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(...
分类:
其他好文 时间:
2015-04-13 14:32:59
阅读次数:
108
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2015-04-13 12:26:38
阅读次数:
121
Given an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your algorithm to use onlyO(...
分类:
其他好文 时间:
2015-04-13 12:20:33
阅读次数:
101
拓扑排序,不开心持续中
#include
#include
#include
#include
#define maxn 2100
using namespace std;
vector >mapp;
int head[maxn];
int n;
void solve()
{
queueroot;
for(int i=0;i<n;i++)
{
if(!head[i]) root.pus...
分类:
其他好文 时间:
2015-04-13 09:31:28
阅读次数:
114
题目如下:
Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,
Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
我的代码:...
分类:
编程语言 时间:
2015-04-12 16:16:46
阅读次数:
105
KIDx's TriangleTime Limit:2000/1000MS (Java/Others)Memory Limit:128000/64000KB (Java/Others)SubmitStatisticNext ProblemProblem DescriptionOne day, KID...
分类:
其他好文 时间:
2015-04-11 14:39:30
阅读次数:
118
int[][] triangle = new int[6][6]; int i, j, k = 0; for (i = 0; i < triangle.length; i++) { triangle[i][0] = 1; triangle[i][i] = 1; } for (...
分类:
其他好文 时间:
2015-04-10 22:20:16
阅读次数:
155