杨辉三角,这次要输出第rowIndex行

用滚动数组t进行递推

t[(i+1)%2][j] = t[i%2][j] + t[i%2][j - 1];

 class Solution {
public:
vector<int> getRow(int rowIndex) {
if(rowIndex < ) return vector<int>(rowIndex + ,);
int n = rowIndex;
vector<int> t[];
for(int i = ; i < ; ++i){
t[i].resize(n + , );
}
for(int i = ; i <= n; ++i){
for(int j = ; j < i; ++j){
t[(i+)%][j] = t[i%][j] + t[i%][j - ];
}
}
return t[(n+) % ];
}
};

Leetcode 119 Pascal's Triangle II 数论递推的更多相关文章

  1. [LeetCode] 119. Pascal's Triangle II 杨辉三角 II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  2. [LeetCode] 119. Pascal's Triangle II 杨辉三角之二

    Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note t ...

  3. LeetCode 119. Pascal's Triangle II (杨辉三角之二)

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  4. LeetCode 119 Pascal's Triangle II

    Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Ret ...

  5. leetcode 119 Pascal's Triangle II ----- java

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...

  6. Java [Leetcode 119]Pascal's Triangle II

    题目描述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return ...

  7. C#解leetcode:119. Pascal's Triangle II

    题目是: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return  ...

  8. Java for LeetCode 119 Pascal's Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  9. leetcode 118. Pascal's Triangle 、119. Pascal's Triangle II 、120. Triangle

    118. Pascal's Triangle 第一种解法:比较麻烦 https://leetcode.com/problems/pascals-triangle/discuss/166279/cpp- ...

随机推荐

  1. ios app打ipa包

    在app上传到appstore之前,我们通常要经过打包测试的步骤,导出到testFlight中.或者其他第三方的平台里面进行测试,这时候就需要打包成ipa包导出.好了,废话不多说,上图.步骤如下: 1 ...

  2. dede列表页分页地址优化(不同url相同内容问题解决)<转自http://www.966266.com>

    <注明,完全转自http://www.966266.com/seoblog/?p=75> 存在问题 DEDE默认分类分页地址存在不同URL相同内容问题,导致内容重复,对SEO非常不利.情况 ...

  3. Floyd | | jzoj[1218] | | [Usaco2009 Dec]Toll 过路费 | | BZOJ 1774 | | 我也不知道该怎么写

    写在前面:老师说这一道题是神题,事实上确实如此,主要是考察对Floyd的理解 ******************************题目.txt************************* ...

  4. cinder backup

    cinder 备份提供的驱动服务有: cinder/backup/drivers/ceph.py:def get_backup_driver(context): cinder/backup/drive ...

  5. linux上安装jdk并添加环境变量

    ==========ubuntu============================= http://www.oracle.com/technetwork/java/javasebusiness/ ...

  6. c# 框架学习(nop )总结-------删除功能

    删除直接使用(框架中以封装好的) 控制中写就可以啦 public ActionResult Delete(int id) { //权限位置(若需要的话)var individual = _indivi ...

  7. c# 通过关键字查询

    1:首先需要在前端显示界面View视图中添加查询按钮: <div> <div>@Html.NopLabelFor(model => model.IndividualNam ...

  8. ios initialize和init等方法

    在程序运行过程中,创建多个类对象,只会调用一次initialize  [ɪˈnɪʃəˌlaɪz] .而创建几个类对象就会调用几次init; 创建一个类aa,分别重写 initialize和init方法 ...

  9. JS-字符串操作,查找显示高亮

    <!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content=&q ...

  10. XproerIM产品使用手册

      1.  产品介绍 版权所有:(c)2009-2016 荆门泽优软件有限公司 保留所有权利. 产品官网:http://www.ncmem.com/apps/xproerim/index.asp 安装 ...