偷个懒,dp以后再说。

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param n int整型 
# @return int整型
#
class Solution:
    def BSTCount(self , n: int) -> int:
        # write code here
        # 卡塔兰数
        # C_n = (2*n*C_n-1)/(n+1)
        # 递归用dp,直接算
        if n == 1:
            return 1
        import math
        # 直接组合数
        catalan = math.comb(2*n, n) // (n+1)
        return catalan