{
  "type": "code_options",
  "author": "https://github.com/begeekmyfriend/leetcode",
  "source": "solution.md",
  "exercise_id": "b83b2c495c46406e8776d85e98306307",
  "keywords": "树,二叉搜索树,数学,动态规划,二叉树",
  "title": "不同的二叉搜索树",
  "desc": [
    {
      "content": "\n<div class=\"notranslate\">\n<p>给你一个整数 <code>n</code> ，求恰由 <code>n</code> 个节点组成且节点值从 <code>1</code> 到 <code>n</code> 互不相同的 <strong>二叉搜索树</strong>\n有多少种？返回满足题意的二叉搜索树的种数。</p>",
      "language": "markdown"
    },
    {
      "content": "\n<p>&nbsp;</p>",
      "language": "markdown"
    },
    {
      "content": "\n<p><strong>示例 1：</strong></p>\n<img style=\"width: 600px; height: 148px;\" src=\"https://assets.leetcode.com/uploads/2021/01/18/uniquebstn3.jpg\"\nalt=\"\">\n<pre><strong>输入：</strong>n = 3\n<strong>输出：</strong>5\n</pre>",
      "language": "markdown"
    },
    {
      "content": "\n<p><strong>示例 2：</strong></p>",
      "language": "markdown"
    },
    {
      "content": "\n<pre><strong>输入：</strong>n = 1\n<strong>输出：</strong>1\n</pre>",
      "language": "markdown"
    },
    {
      "content": "\n<p>&nbsp;</p>",
      "language": "markdown"
    },
    {
      "content": "\n<p><strong>提示：</strong></p>",
      "language": "markdown"
    },
    {
      "content": "\n<ul>\n<li><code>1 &lt;= n &lt;= 19</code></li>\n</ul>\n</div>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <stdc++.h>\nusing namespace std;\nclass Solution\n{\npublic:\n\tint numTrees(int n)\n\t{\n\t\tvector<int> sum(n + 1);\n\t\tsum[0] = 1;\n\t\tfor (int i = 1; i <= n; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < i; j++)\n\t\t\t{\n\t\t\t\tsum[i] += sum[j] * sum[i - j - 1];\n\t\t\t}\n\t\t}\n\t\treturn sum[n];\n\t}\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-86063bc2e4f9408c90a68336b7d0b233",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600469926"
}