118. Pascal's Triangle

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]
]
public class Solution {
    public List> generate(int numRows) {
        List> rec = new ArrayList>(numRows);
        if(numRows <= 0)
          return rec;
        
        for(int i=0;i arr = new ArrayList(i);
          for(int j=0;j<=i;j++)
          {   
              if(j==0)
                arr.add(1);
              else if(j>0&&j

你可能感兴趣的:(118. Pascal's Triangle)