Count of BSTs
catalan numbers but think of the derivation.
I can do 1 way for 0 and 1 nodes. For 2, I can iterate for all nodes to make root and the make a bst with cnt(left rem) * cnt(right rem)
int numTrees(int n) {
vector<int> dp(n + 1);
dp[0] = 1;
dp[1] = 1;
for (int i = 2; i <= n; i++) {
for (int root = 1; root <= i; root++)
dp[i] += dp[root - 1] * dp[i - root];
}
return dp[n];
}