问题 ​​https://leetcode-cn.com/problems/pascals-triangle-ii/​

练习使用JavaScript解答

 

/**
* @param {number} rowIndex
* @return {number[]}
*/
var getRow = function(rowIndex) {
var arr = [1], t1, t2;
for(var i=1;i<=rowIndex;++i) {
t1 = 1;
for(var j=1;j<=i;++j) {
t2 = 0;
if(arr[j])
t2 = arr[j];
arr[j] = t1 + t2;
t1 = t2;
}
}
return arr;
};