From a0edc60d1fd08db91138daf430a97894a354bd98 Mon Sep 17 00:00:00 2001 From: jinbudaily <18336218010@163.com> Date: Wed, 26 Jul 2023 16:21:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E8=B7=9D=E7=A6=BB=E7=B3=BB=E5=88=97=20=E6=8E=92=E7=89=88?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0072.编辑距离.md | 19 +++++++++++-------- problems/0115.不同的子序列.md | 18 ++++++++++-------- .../0583.两个字符串的删除操作.md | 16 +++++++++------- ...编辑距离,卡尔做了三步铺垫.md | 8 ++------ 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/problems/0072.编辑距离.md b/problems/0072.编辑距离.md index 703e8913..1ed9a860 100644 --- a/problems/0072.编辑距离.md +++ b/problems/0072.编辑距离.md @@ -40,8 +40,8 @@ exection -> execution (插入 'u') * 0 <= word1.length, word2.length <= 500 * word1 和 word2 由小写英文字母组成 -# 算法公开课 -**《代码随想录》算法视频公开课:[动态规划终极绝杀! LeetCode:72.编辑距离](https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 +## 算法公开课 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划终极绝杀! LeetCode:72.编辑距离](https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 ## 思路 @@ -227,8 +227,8 @@ public: ## 其他语言版本 +### Java: -Java: ```java public int minDistance(String word1, String word2) { int m = word1.length(); @@ -256,7 +256,8 @@ public int minDistance(String word1, String word2) { } ``` -Python: +### Python: + ```python class Solution: def minDistance(self, word1: str, word2: str) -> int: @@ -274,7 +275,8 @@ class Solution: return dp[-1][-1] ``` -Go: +### Go: + ```Go func minDistance(word1 string, word2 string) int { m, n := len(word1), len(word2) @@ -310,8 +312,8 @@ func Min(args ...int) int { } ``` +### Javascript: -Javascript: ```javascript const minDistance = (word1, word2) => { let dp = Array.from(Array(word1.length + 1), () => Array(word2.length+1).fill(0)); @@ -338,7 +340,7 @@ const minDistance = (word1, word2) => { }; ``` -TypeScript: +### TypeScript: ```typescript function minDistance(word1: string, word2: string): number { @@ -373,7 +375,7 @@ function minDistance(word1: string, word2: string): number { }; ``` -C: +### C: ```c @@ -405,3 +407,4 @@ int minDistance(char * word1, char * word2){ + diff --git a/problems/0115.不同的子序列.md b/problems/0115.不同的子序列.md index 8c82880d..d925c5de 100644 --- a/problems/0115.不同的子序列.md +++ b/problems/0115.不同的子序列.md @@ -157,8 +157,8 @@ public: ## 其他语言版本 +### Java: -Java: ```java class Solution { public int numDistinct(String s, String t) { @@ -182,7 +182,8 @@ class Solution { } ``` -Python: +### Python: + ```python class Solution: def numDistinct(self, s: str, t: str) -> int: @@ -200,7 +201,8 @@ class Solution: return dp[-1][-1] ``` -Python3: +### Python3: + ```python class SolutionDP2: """ @@ -234,7 +236,8 @@ class SolutionDP2: return dp[-1] ``` -Go: +### Go: + ```go func numDistinct(s string, t string) int { dp:= make([][]int,len(s)+1) @@ -259,8 +262,8 @@ func numDistinct(s string, t string) int { } ``` +### Javascript: -Javascript: ```javascript const numDistinct = (s, t) => { let dp = Array.from(Array(s.length + 1), () => Array(t.length +1).fill(0)); @@ -283,7 +286,7 @@ const numDistinct = (s, t) => { }; ``` -TypeScript: +### TypeScript: ```typescript function numDistinct(s: string, t: string): number { @@ -312,9 +315,8 @@ function numDistinct(s: string, t: string): number { ``` - -

+ diff --git a/problems/0583.两个字符串的删除操作.md b/problems/0583.两个字符串的删除操作.md index 48d15b0b..505a4e33 100644 --- a/problems/0583.两个字符串的删除操作.md +++ b/problems/0583.两个字符串的删除操作.md @@ -17,9 +17,9 @@ * 解释: 第一步将"sea"变为"ea",第二步将"eat"变为"ea" -# 算法公开课 +## 算法公开课 -**《代码随想录》算法视频公开课:[动态规划之子序列,还是为了编辑距离做铺垫 | LeetCode:583.两个字符串的删除操(https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 +**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[LeetCode:583.两个字符串的删除操](https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 ## 思路 @@ -143,8 +143,8 @@ public: ## 其他语言版本 +### Java: -Java: ```java // dp数组中存储word1和word2最长相同子序列的长度 class Solution { @@ -215,8 +215,8 @@ class Solution { } ``` +### Python: -Python: ```python class Solution: def minDistance(self, word1: str, word2: str) -> int: @@ -234,7 +234,8 @@ class Solution: return dp[-1][-1] ``` -Go: +### Go: + ```go func minDistance(word1 string, word2 string) int { dp := make([][]int, len(word1)+1) @@ -267,7 +268,8 @@ func min(a, b int) int { return b } ``` -Javascript: +### Javascript: + ```javascript // 方法一 var minDistance = (word1, word2) => { @@ -309,7 +311,7 @@ var minDistance = function (word1, word2) { }; ``` -TypeScript: +### TypeScript: > dp版本一: diff --git a/problems/为了绝杀编辑距离,卡尔做了三步铺垫.md b/problems/为了绝杀编辑距离,卡尔做了三步铺垫.md index b8adffc7..50287ce2 100644 --- a/problems/为了绝杀编辑距离,卡尔做了三步铺垫.md +++ b/problems/为了绝杀编辑距离,卡尔做了三步铺垫.md @@ -163,8 +163,8 @@ else { ## 其他语言版本 +### Java: -Java: ```java class Solution { public int minDistance(String word1, String word2) { @@ -193,11 +193,6 @@ class Solution { } ``` -Python: - - -Go: - @@ -205,3 +200,4 @@ Go: +