Leetcode - Array - 118. Pascal's Triangle(杨辉三角)

1. Problem Description

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]

]

 

简单模拟。

 

2. My solution

   vector > generate(int numRows)
    {
        vector< vector >res;
        for(int i=0; itmp;
            res.push_back(tmp);
            res[i].push_back(1);
            int numCols=i+1;
            for(int j=1; j


你可能感兴趣的:(leetcode,leetcode,杨辉三角)