See below.

`` ``` `

```
def numTrees(self, n):
if n == 0 or n == 1:
return 1
else:
result = [0 for i in range(n+1)]
result[0], result[1] = 1, 1
for i in range(2, n+1):
for k in range(1, i+1):
result[i] += result[k-1]*result[i-k]
return result[n]
```

`` ``` `