[leetcode] Pascal's Triangle II
来源:互联网 发布:打印机无法网络打印 编辑:程序博客网 时间:2024/06/06 02:50
Pascal's Triangle II
#include <iostream>#include <vector>using namespace std;class Solution {public: vector<int> getRow(int rowIndex) { vector<int> res(rowIndex+1); for (int i=0; i<=rowIndex; i++) { for (int j=i; j>=0; j--) { if (j==0||j==i) { res[j]=1; }else{ res[j]=res[j-1]+res[j];//update } } } /*for (int i=0; i<rowIndex; i++) { cout<<res[i]<<" "; } cout<<res[rowIndex]<<endl;*/ return res; }};int main(){ Solution so; int n=4; so.getRow(n); return 0;}
0 0
- LeetCode Pascal's Triangle II
- LeetCode: Pascal's Triangle II
- [LeetCode] Pascal's Triangle II
- [Leetcode] Pascal's Triangle II
- 【leetcode】Pascal's Triangle II
- LeetCode - Pascal's Triangle II
- Leetcode: Pascal's Triangle II
- LeetCode-Pascal's Triangle II
- [leetcode] Pascal's Triangle II
- LeetCode - Pascal's Triangle II
- LeetCode | Pascal's Triangle II
- Pascal's Triangle II -leetcode
- Leetcode Pascal's Triangle II
- [LeetCode] Pascal's Triangle II
- Leetcode: Pascal's Triangle II
- Leetcode Pascal's Triangle II
- LeetCode Pascal's Triangle II
- LeetCode Pascal's Triangle II
- js取整函数
- java设计模式-代理模式小结
- 多方位解析PHP vs Node.js之争
- BZOJ 3316 JC loves Mkk 二分答案+单调队列
- 连接数据库错误The Network Adapter could not establish the connection
- [leetcode] Pascal's Triangle II
- hdu1106 排序 堆排序
- StateMachine与State模式
- Codeforces Round #285 (Div. 2) D. Misha and Permutations Summation 康托展开 树状数组+二分
- Dispatcher initialization failed怎么解决
- HashSet和HashMap的区别
- iOS裁剪图片
- 2012年11月6日 不存在
- 【学QT】 3 - DEBUG集子