更新 编辑距离系列 排版格式修复

This commit is contained in:
jinbudaily
2023-07-26 16:21:21 +08:00
parent 9b0c0f20dc
commit a0edc60d1f
4 changed files with 32 additions and 29 deletions

View File

@ -40,8 +40,8 @@ exection -> execution (插入 'u')
* 0 <= word1.length, word2.length <= 500 * 0 <= word1.length, word2.length <= 500
* word1 和 word2 由小写英文字母组成 * word1 和 word2 由小写英文字母组成
# 算法公开课 ## 算法公开课
**《代码随想录》算法视频公开课:[动态规划终极绝杀! LeetCode72.编辑距离](https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。 **[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[动态规划终极绝杀! LeetCode72.编辑距离](https://www.bilibili.com/video/BV1we4y157wB/),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
## 思路 ## 思路
@ -227,8 +227,8 @@ public:
## 其他语言版本 ## 其他语言版本
### Java
Java
```java ```java
public int minDistance(String word1, String word2) { public int minDistance(String word1, String word2) {
int m = word1.length(); int m = word1.length();
@ -256,7 +256,8 @@ public int minDistance(String word1, String word2) {
} }
``` ```
Python ### Python
```python ```python
class Solution: class Solution:
def minDistance(self, word1: str, word2: str) -> int: def minDistance(self, word1: str, word2: str) -> int:
@ -274,7 +275,8 @@ class Solution:
return dp[-1][-1] return dp[-1][-1]
``` ```
Go ### Go
```Go ```Go
func minDistance(word1 string, word2 string) int { func minDistance(word1 string, word2 string) int {
m, n := len(word1), len(word2) m, n := len(word1), len(word2)
@ -310,8 +312,8 @@ func Min(args ...int) int {
} }
``` ```
### Javascript
Javascript
```javascript ```javascript
const minDistance = (word1, word2) => { const minDistance = (word1, word2) => {
let dp = Array.from(Array(word1.length + 1), () => Array(word2.length+1).fill(0)); 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 ```typescript
function minDistance(word1: string, word2: string): number { function minDistance(word1: string, word2: string): number {
@ -373,7 +375,7 @@ function minDistance(word1: string, word2: string): number {
}; };
``` ```
C ### C
```c ```c
@ -405,3 +407,4 @@ int minDistance(char * word1, char * word2){
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>

View File

@ -157,8 +157,8 @@ public:
## 其他语言版本 ## 其他语言版本
### Java
Java
```java ```java
class Solution { class Solution {
public int numDistinct(String s, String t) { public int numDistinct(String s, String t) {
@ -182,7 +182,8 @@ class Solution {
} }
``` ```
Python ### Python
```python ```python
class Solution: class Solution:
def numDistinct(self, s: str, t: str) -> int: def numDistinct(self, s: str, t: str) -> int:
@ -200,7 +201,8 @@ class Solution:
return dp[-1][-1] return dp[-1][-1]
``` ```
Python3: ### Python3:
```python ```python
class SolutionDP2: class SolutionDP2:
""" """
@ -234,7 +236,8 @@ class SolutionDP2:
return dp[-1] return dp[-1]
``` ```
Go ### Go
```go ```go
func numDistinct(s string, t string) int { func numDistinct(s string, t string) int {
dp:= make([][]int,len(s)+1) dp:= make([][]int,len(s)+1)
@ -259,8 +262,8 @@ func numDistinct(s string, t string) int {
} }
``` ```
### Javascript:
Javascript:
```javascript ```javascript
const numDistinct = (s, t) => { const numDistinct = (s, t) => {
let dp = Array.from(Array(s.length + 1), () => Array(t.length +1).fill(0)); 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 ```typescript
function numDistinct(s: string, t: string): number { function numDistinct(s: string, t: string): number {
@ -312,9 +315,8 @@ function numDistinct(s: string, t: string): number {
``` ```
<p align="center"> <p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>

View File

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

View File

@ -163,8 +163,8 @@ else {
## 其他语言版本 ## 其他语言版本
### Java
Java
```java ```java
class Solution { class Solution {
public int minDistance(String word1, String word2) { public int minDistance(String word1, String word2) {
@ -193,11 +193,6 @@ class Solution {
} }
``` ```
Python
Go
@ -205,3 +200,4 @@ Go
<a href="https://programmercarl.com/other/kstar.html" target="_blank"> <a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/> <img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a> </a>