LeetCode刷题实战119: 杨辉三角 II
Given an integer rowIndex, return the rowIndexth row of the Pascal's triangle.
Notice that the row index starts from 0.
题意
示例:
输入: 3
输出: [1,3,3,1]
解题
class Solution {
public ListgetRow(int rowIndex) {
Integer[] result = new Integer[rowIndex+1];
Arrays.fill(result, 0);
result[0] = 1;
for(int i = 1; ifor(int j=i;j>0;j--) {
result[j] = result[j] + result[j-1];
}
}
return Arrays.asList(result);
}
}
LeetCode刷题实战116:填充每个节点的下一个右侧节点指针
LeetCode刷题实战117:填充每个节点的下一个右侧节点指针 II
评论