Easy dp solution - catalan number


#1
int Solution::numTrees(int A) {
vector<int> dp(20, 0);
dp[1] = 1;
dp[2] = 2;
for(int i = 3;i<= A;i++){
    for(int j = 1;j<=i;j++){
        int x = j - 1;
        int y = i - j;
        dp[i] += max(dp[x],1)*max(1,dp[y]);
    }
}
return dp[A];
}