MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / numTrees

Method numTrees

AwesomeAlgorithms/CatalanNumber.py:11–15  ·  view source on GitHub ↗
(self, n)

Source from the content-addressed store, hash-verified

9
10class Solution:
11 def numTrees(self, n):
12 # n为0的时候输出1
13 if n == 0 or n == None:
14 return 1
15 return self.factorial(n << 1) // (self.factorial(n) * self.factorial(n + 1))
16 # 定义一个函数求取n的阶乘
17 def factorial(self, n):
18 result = 1

Callers 1

CatalanNumber.pyFile · 0.80

Calls 1

factorialMethod · 0.95

Tested by

no test coverage detected