class Solution {
public:
vector<vector<int>> generate(int numRows) {
vector<vector<int>> vv;
vector<int> v_arr[numRows+]; if( numRows <= ) return vv;
v_arr[].push_back();
vv.push_back(v_arr[]);
if(numRows == ) return vv;
for(int row=;row<=numRows;row++){
v_arr[row].push_back(); // 1 at begin
int pre_len = v_arr[row-].size();
for(int i=;i<pre_len-;i++){
v_arr[row].push_back(v_arr[row-][i]+v_arr[row-][i+]);
}
v_arr[row].push_back(); //1 at end
vv.push_back(v_arr[row]);
} return vv; }
};

Pascal's Triangle的更多相关文章

  1. [LeetCode] 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, ...

  2. [LeetCode] Pascal's Triangle 杨辉三角

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  3. 【leetcode】Pascal's Triangle II

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

  4. 【leetcode】Pascal's Triangle

    题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...

  5. LeetCode 118 Pascal's Triangle

    Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows  ...

  6. 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 ...

  7. LeetCode - Pascal's Triangle II

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

  8. 【leetcode】Pascal's Triangle I & II (middle)

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  9. 118. Pascal's Triangle

    题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, ...

  10. [LeetCode]题解(python):119 Pascal's Triangle II

    题目来源 https://leetcode.com/problems/pascals-triangle-ii/ Given an index k, return the kth row of the ...

随机推荐

  1. gdb 7.11

    因为CentOS自带的GDB版本有点低,所以下载了最新的gdb 7.11编译以后,调试过程中提示以下错误. Python Exception <type 'exceptions.NameErro ...

  2. C# 整形、双精度浮点型、字符串与字节型的相互转化

    整形.双精度浮点型.字符串与字节型的相互转化,如下 using System; using System.Collections.Generic; using System.Linq; using S ...

  3. JavaScript实现,判断一个点是否在多边形内

    //定义点的结构体 function point(){ this.x=0; this.y=0; } //计算一个点是否在多边形里,参数:点,多边形数组 function PointInPoly(pt, ...

  4. intellij idea exclude from compile后怎么加回来

    File->Settings-> Build,Execution,Deployment->Compiler-> Execludes

  5. 分子模拟软件Schrodinger Suites 2015安装

    安装平台:redhat 5.6 schrodinger 2015 先把schrodinger_2015.iso 挂载到/mnt >>>> mount -o loop schro ...

  6. redhat vim编辑器永久添加行号

    cd ~ vim .vimrc 第一行加入: set nu :wq 保存退出,即可 如果想取消设置,同理删除set nu即可

  7. PostgreSQL Configuration – managing scary settings

    When it comes to highly available database servers and configuration, a very important aspect is whe ...

  8. php面向对象(OOP)编程完全教程

    摘自:http://www.php-note.com/article/detail/41 面向对象编程(OOP)是我们编程的一项基本技能,PHP5对OOP提供了良好的支持.如何使用OOP的思想来进行P ...

  9. CCF真题之相邻数对

    201409-1 问题描述 给定n个不同的整数,问这些数中有多少对整数,它们的值正好相差1. 输入格式 输入的第一行包含一个整数n,表示给定整数的个数. 第二行包含所给定的n个整数. 输出格式 输出一 ...

  10. bean在容器上的生命周期

            初始化两种方法:         1,使用init-method属性指定那个方法在bean依赖关系设置好后自动执行.         2,实现initializingBean接口 实现 ...