Python 3.5 One-Liner


#1
from functools import lru_cache

class Solution:
    # @param A : integer
    # @return an integer
    @lru_cache()
    def numTrees(self, n):
        return 1 if n == 0 else sum(self.numTrees(i) * self.numTrees(n - i - 1) for i in range(0, n))