Open
Description
/**
* @param {number} numRows
* @return {number[][]}
*/
var generate = function (numRows) {
var result = [];
for (var i = 0; i < numRows; ++i) {
result[i] = [1];
for (var j = 1; j <= i; ++j) {
if (j === i) {
result[i][j] = 1;
} else {
if (result[i - 1][j] !== undefined) {
result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
}
}
}
}
return result;
};
Metadata
Metadata
Assignees
Labels
No labels