From 1590897824de40843710804d6a0397eca0131ee1 Mon Sep 17 00:00:00 2001 From: LiangDazhu <42199191+LiangDazhu@users.noreply.github.com> Date: Fri, 28 May 2021 23:33:19 +0800 Subject: [PATCH] =?UTF-8?q?Update=200096.=E4=B8=8D=E5=90=8C=E7=9A=84?= =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=90=9C=E7=B4=A2=E6=A0=91.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added python version code --- problems/0096.不同的二叉搜索树.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/problems/0096.不同的二叉搜索树.md b/problems/0096.不同的二叉搜索树.md index cee0102f..a9631315 100644 --- a/problems/0096.不同的二叉搜索树.md +++ b/problems/0096.不同的二叉搜索树.md @@ -186,7 +186,16 @@ class Solution { ``` Python: - +```python +class Solution: + def numTrees(self, n: int) -> int: + dp = [0] * (n + 1) + dp[0], dp[1] = 1, 1 + for i in range(2, n + 1): + for j in range(1, i + 1): + dp[i] += dp[j - 1] * dp[i - j] + return dp[-1] +``` Go: ```Go