class Solution {
public List<Integer> getRow(int rowIndex) {
int[][] arr = new int[rowIndex+1][rowIndex+1];
List<Integer> subList = new ArrayList<>();
for(int i=0;i<=rowIndex;i++){
for(int j=0;j<=i;j++){
if(j==0||j==i){
arr[i][j]=1;
}else{
arr[i][j]=arr[i-1][j]+arr[i-1][j-1];
}
if(i==rowIndex)
subList.add(arr[i][j]);
}
}
return subList;
}
}
杨辉三角||和杨辉三角的区别在于 返回的数值类型不一样,申请一个list,在最后一行的时候再用