Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 565 Bytes

File metadata and controls

23 lines (20 loc) · 565 Bytes

Array

Screen Shot 2022-12-26 at 1 35 22 AM

/**
 * @param {number} rowIndex
 * @return {number[]}
 */
var getRow = function(rowIndex) {
    let stack = [];
    for(let i = 0; i <= rowIndex; i++) {
        stack[i] = [];
        stack[i][0] = 1;
        for(let j = 1; j < i; j++) {
            stack[i][j] = stack[i - 1][j - 1] + stack[i - 1][j];
        }
        stack[i][i] = 1;
    }
    return stack[rowIndex];
};