https://leetcode.com/problems/pascals-triangle-ii/
Recursion –> top down DP memoization1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16class Solution {
// int[][] memo;
private int getNum(int row,int col){
if(row==0||col==0||col==row) return 1;
// if(memo[row][col]>0) return memo[row][col];
return memo[row][col]=getNum(row-1,col-1)+getNum(row-1,col);
}
public List<Integer> getRow(int rowIndex) {
List<Integer> ans=new ArrayList<>();
// memo = new int[rowIndex+1][rowIndex+1];
for(int i=0;i<=rowIndex;i++){
ans.add(getNum(rowIndex,i));
}
return ans;
}
}