We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difficulty: 中等
Related Topics: 树, 二叉搜索树, 数学, 动态规划, 二叉树
给你一个整数 n ,求恰由 n 个节点组成且节点值从 1 到 n 互不相同的 二叉搜索树 有多少种?返回满足题意的二叉搜索树的种数。
n
1
示例 1:
输入:n = 3 输出:5
示例 2:
输入:n = 1 输出:1
提示:
1 <= n <= 19
Language: JavaScript
/** * @param {number} n * @return {number} */ // 数学 var numTrees = function(n) { let res = 1 for (let i = 1; i < n; i++) { res = res * 2 * (2 * i + 1) / (i + 2) } return res }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
96. 不同的二叉搜索树
Description
Difficulty: 中等
Related Topics: 树, 二叉搜索树, 数学, 动态规划, 二叉树
给你一个整数
n
,求恰由n
个节点组成且节点值从1
到n
互不相同的 二叉搜索树 有多少种?返回满足题意的二叉搜索树的种数。示例 1:
示例 2:
提示:
1 <= n <= 19
Solution
Language: JavaScript
The text was updated successfully, but these errors were encountered: