杨辉三角,这次要输出第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. js 验证码 倒计时60秒

    js 验证码 倒计时60秒 <input type="button" id="btn" value="免费获取验证码" /> & ...

  2. (引用 )自动化测试报告HTMLtestrunner

    1>下载HTMLTestRunner.py文件,地址为: http://tungwaiyip.info/software/HTMLTestRunner.html   Windows平台: 将下载 ...

  3. GridView中DropDownList

    <asp:TemplateField HeaderText="下拉框"> <ItemTemplate> <cc1:MyDropDownList ID= ...

  4. 使用jquery form插件进行异步带文件的表单提交

    引入form插件与jquery 的js文件后 获取表单的jq对象 然后.ajaxSubmit提交表单即可 实现添加品牌的异步表单提交 function addBarandImg(formId) { $ ...

  5. SWT, JFace必须的jar包和有可能会用到的jar

    先附上一篇转载的, 转自CSDN, 原文地址:http://blog.csdn.net/nabber/article/details/1879511 如果阁下看到了这篇文章,估计你已经碰到了这样的困那 ...

  6. SAP 设置周期性的后台程序,SM36,图解操作 (转)

    SM36是设置SAP周期性运行的事务码 来测试一下,首先先写一个程序: 我有一个zzp_people2的数据表. DATA : INT1 TYPE I. DATA : ITAB LIKE ZZP_PE ...

  7. go 的 time ticker 设置定时器

    上示例 package main import ( // "bytes" // "encoding/json" "fmt" // " ...

  8. tp 中关于大小写的问题

    ThinkPHP3.2.3升级的若干问题和注意事项(持续更新) 现把ThinkPHP3.2.2在升级到3.2.3的过程中需要注意和可能的问题整理如下: (无论如何,在升级之前请确认备份) 1.首先3. ...

  9. mybatis mapper.xml 配置文件问题(有的错误xml是不报的) 导致服务无法启动 。

    转载自 开源编程 一舟mybatsi xml编译报错,tomcat启动一直循环,导致内存溢出,启动失败 mapper.xml怎么知道有没有编译错误,哪个位置有错误 这应该是mybatis的一个bug, ...

  10. c# 调用分页(控制器端的)与时间的格式

    1.在操作的model中: 2.在控制器中: , command.PageSize);//将从数据库获取到的集合进行分页 var gridModel = new DataSourceResult { ...