AFFILIATE LINKS
Great resource I use to learn algorithms.
40% off Tech Interview Pro: http://techinterviewpro.com/terriblewhiteboard
20% off CoderPro: http://coderpro.com/terriblewhiteboard
Here is the full implementation.
/**
* @param {number} rowIndex
* @return {number[]}
*/
let getRow = function(rowIndex) {
let row = [];
if (rowIndex < 0) {
return row;
}
row.push(1);
for (let i = 1; i <= rowIndex; i++) {
for (let j = row.length - 1; j > 0; j--) {
row[j] = row[j - 1] + row[j];
}
row.push(1);
}
return row;
};