给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种?
示例1
输入
3
输出
5
说明
加载中...
import java.util.*; public class Solution { /** * * @param n int整型 * @return int整型 */ public int numTrees (int n) { // write code here } }
class Solution { public: /** * * @param n int整型 * @return int整型 */ int numTrees(int n) { // write code here } };
# # # @param n int整型 # @return int整型 # class Solution: def numTrees(self , n ): # write code here
/** * * @param n int整型 * @return int整型 */ function numTrees( n ) { // write code here } module.exports = { numTrees : numTrees };
# # # @param n int整型 # @return int整型 # class Solution: def numTrees(self , n ): # write code here
3
5