Based on the quora question listed here:

https://leetcode.com/discuss/42208/0ms-easy-to-understand-solution-in-c

```
public int NumTrees(int n)
{
int[] f = new int[n + 1];
f[0] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < i; j++)
{
f[i] += f[j] * f[i - j - 1];
}
}
return f[n];
}
```