https://leetcode.com/problems/pascals-triangle-ii/
数字三角形,递归解
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
var getRow = function(rowIndex) { if (rowIndex === 0) { return [1] } if (rowIndex > 0) { let a = [1] let p = getRow(rowIndex - 1) for (let i = 1; i < rowIndex; i++) { a[i] = p[i - 1] + p[i] } a.push(1) return a } };
|