Day 60: Force buckle 118, Yang Hui triangle

Address: leetcode-cn.com/problems/pa…

B: That’s right.

var generate = function(numRows) {
  let res = [];
  for(let i = 0; i < numRows; i++)
  {
    const arr = new Array(i+1).fill(1);
    for(let j = 1; j < arr.length - 1; j++)
    {
      arr[j] = res[i - 1][j - 1] + res[i - 1][j];
    }
    res.push(arr);
  }
  return res;
};
Copy the code

Execution time: 80 ms, beating 73.17% of all JavaScript commits

Memory consumption: 37.7 MB, beating 29.14% of all JavaScript commits