87 days: Li Kou 119, Yang Hui triangle II

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

Yang Hui triangulation takes the required position value

var getRow = function(rowIndex) {
  let res = [];
  for(let i = 0; i <= rowIndex; 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[rowIndex];
};
Copy the code

Execution time: 72 ms, beating 96.14% of all JavaScript commits

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