大致思路:动态规划结合杨辉三角的定义即可。
public class Solution {
public ArrayList<Integer> getRow (int rowIndex) {
// write code here
int[] res = new int[rowIndex+1];
res[0] = 1;
for(int i = 1;i<=rowIndex;i++){
res[i] = 1;
for(int j = i-1;j>0;j--) res[j] = res[j-1]+res[j];
}
ArrayList<Integer> tmp = new ArrayList<>();
for(int num:res) tmp.add(num);
return tmp;
}
}