题目描述
Given an index k, return the kth row of the Pascal’s triangle.
For example, given k = 3,
Return [1,3,3,1].
大白话
给行号n,输出第n行的杨辉三角序列
题目链接
AC代码
var getRow = function(rowIndex) {
var nums = [1];
for(var i = 1; i <= rowIndex; i++){
for(var j = i - 1; j > 0; j--){
nums[j] += nums[j-1];
}
nums[i] = 1;
}
return nums;
};