[118]Pascal's Triangle
来源:互联网 发布:js如何实现随机掉落 编辑:程序博客网 时间:2024/04/30 09:43
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]]
class Solution {public: vector<vector<int> > generate(int numRows) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<vector<int> > rows; vector<int> preRow; vector<int> currRow; for(int i = 0; i < numRows; i++) { currRow.clear(); for(int j = 0; j <= i; j++) { if(j == i || j == 0) currRow.push_back(1); else currRow.push_back(preRow[j-1]+preRow[j]); } rows.push_back(currRow); preRow = currRow; } return rows; } };
- [118]Pascal's Triangle
- 118Pascal's Triangle
- 118Pascal's Triangle
- 118Pascal's Triangle
- 118 Pascal's Triangle
- 118Pascal's Triangle
- [118] Pascal's Triangle
- 118 Pascal's Triangle
- #118 Pascal's Triangle & #119 Pascal's Triangle II
- LeetCode 118: Pascal's Triangle
- LeetCode(118)Pascal's Triangle
- LeetCode: Pascal's Triangle [118]
- LeetCode 118 Pascal's Triangle
- LeetCode 118 Pascal's Triangle
- [leetcode 118] Pascal's Triangle
- leetCode #118 Pascal's Triangle
- LeetCode 118 :Pascal's Triangle
- leetcode-118 Pascal's Triangle
- 数据导入到SAP
- Java判断网络连接是否正常
- 四遥
- Win7下Platform Builder6.0出现"fatal error C1033: cannot open program database '' 解决方案
- HDU 1102 Constructing Roads
- [118]Pascal's Triangle
- 第7周项目二-成员函数、友元函数和一般函数之区别 点类
- PHP安全编程:记住登录状态的安全做法
- Qt中如何给按键加图标(或加背景图片)
- 新九州 -- 如何在类目里添加课程
- TranslateMessage()函数
- NOVA架构 nova-compute启动分析
- 远程连接mysql速度慢的解决方法
- NuSOAP webservice接口使用详解