class Solution:

    def numTrees(self, n):
        """
        :type n: int
        :rtype: int
        """
        dp = [1] + [0] * n
        for i in range(1, n + 1):
            for j in range(i):
                dp[i] += dp[j] * dp[i - j - 1]
        return dp[-1]

c17269b8c008bb25877b288b68d424ed9a5ceb79
<mask token>

class Solution:
    <mask token>

class Solution:

    def numTrees(self, n):
        """
        :type n: int
        :rtype: int
        """
        dp = [1] + [0] * n
        for i in range(1, n + 1):
            for j in range(i):
                dp[i] += dp[j] * dp[i - j - 1]
        return dp[-1]
