想清楚了,安排好细节不难public class Solution { public ArrayList> generate(int numRows) { ArrayList> res = new ArrayList>(); if(numRows tmp = new...
分类:
其他好文 时间:
2015-04-18 06:25:25
阅读次数:
149
AreaTime Limit:1000MSMemory Limit:10000KTotal Submissions:5227Accepted:2342DescriptionBeing well known for its highly innovative products, Merck would...
分类:
其他好文 时间:
2015-04-17 21:53:04
阅读次数:
196
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-17 21:51:24
阅读次数:
142
题目大意:从三角形顶部数字走,每次只能走到这个数字的左下角或者右下角的数字,直到底部,计算走过的线路的数字之和,求这个和的最大值。
#include
#include
#include
using namespace std;
const int MAXN = 105;
int dp[MAXN][MAXN], a[MAXN][MAXN];
int main()
{
...
分类:
其他好文 时间:
2015-04-17 20:35:39
阅读次数:
129
题意:一个数字组成的三角形,像酱: 7 3 8 8 1 0 2 7 4 44 5 2 6 5从最上面的顶点开始,每次可以移动到下一层左右两个点上,选一条路径,走过的点上的值加和最大,输出最大值。解法:经典动态规划问题……数字三角形……每个点可以由上一层相邻的两个点的值转移而来,方程:dp...
分类:
其他好文 时间:
2015-04-16 21:40:00
阅读次数:
186
A -A Very Easy Triangle Counting GameTime Limit:1000MSMemory Limit:64000KB64bit IO Format:%lld & %lluSubmitStatusPracticeACdream 1008DescriptionSpeedc...
分类:
其他好文 时间:
2015-04-16 14:08:54
阅读次数:
112
题目链接https://leetcode.com/problems/pascals-triangle/https://leetcode.com/problems/pascals-triangle-ii/这两道题都是数组操作,需要注意的是II在I的基础上使用滚动数组存储过往的中间结果,这个思想可以注意...
分类:
其他好文 时间:
2015-04-16 06:44:20
阅读次数:
110
/*杨辉三角的简单应用 res[i][j] = res[i-1][j]+res[i-1][j-1](j>0&&j > generate(int numRows) { vector >res; for(int i = 0 ; i ()); for(in...
分类:
其他好文 时间:
2015-04-15 22:54:36
阅读次数:
153
/* 给一个k,返回第k行的杨辉三角 类似动态规划由于只要返回某一行,所以只要用一维维护即可*/class Solution {public: vector getRow(int rowIndex) { vectorres(rowIndex+1,0); ...
分类:
其他好文 时间:
2015-04-15 22:50:07
阅读次数:
103
这两题都比较简单,第一题输出杨辉三角,第二题输出特定的某一行,第二题要求空间复杂度为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