トピック:
トピックリンク: https://leetcode-cn.com/problems/unique-binary-search-trees/
問題解決のアイデア:
沿ってバイナリ検索の異なる種類の数もカタロニア語の数として知られているカトレア番号は、一般的な用語の式であります:
直接式に、あなたはどんなのを得ることができます
コードの実装:
class Solution:
def numTrees(self, n: int) -> int:
res = 1
for i in range(n):
res = res * 2 * (2 * i + 1) // (i + 2)
return res