Skip to content

Commit

Permalink
Merge pull request youngyangyang04#2208 from jinbudaily/master
Browse files Browse the repository at this point in the history
更新 动态规划篇章 排版格式修复
  • Loading branch information
youngyangyang04 committed Jul 27, 2023
2 parents 1340cc3 + 04dd0ec commit 2691e27
Show file tree
Hide file tree
Showing 46 changed files with 341 additions and 300 deletions.
5 changes: 3 additions & 2 deletions problems/0070.爬楼梯.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
* 1 阶 + 2 阶
* 2 阶 + 1 阶

# 视频讲解
## 算法公开课

**《代码随想录》算法视频公开课:[带你学透动态规划-爬楼梯|LeetCode:70.爬楼梯)](https://www.bilibili.com/video/BV17h411h7UH),相信结合视频在看本篇题解,更有助于大家对本题的理解**
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[带你学透动态规划-爬楼梯|LeetCode:70.爬楼梯)](https://www.bilibili.com/video/BV17h411h7UH),相信结合视频在看本篇题解,更有助于大家对本题的理解**


## 思路
Expand Down Expand Up @@ -522,3 +522,4 @@ impl Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

14 changes: 7 additions & 7 deletions problems/0070.爬楼梯完全背包版本.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public:
## 其他语言版本
### Java:
Java:
```java
class Solution {
public int climbStairs(int n) {
Expand All @@ -148,7 +148,7 @@ class Solution {
}
```

Python3:
### Python3:


```python
Expand All @@ -166,8 +166,8 @@ class Solution:
return dp[n]
```

### Go:

Go:
```go
func climbStairs(n int) int {
//定义
Expand All @@ -189,7 +189,8 @@ func climbStairs(n int) int {
}
```

JavaScript:
### JavaScript:

```javascript
var climbStairs = function(n) {
const dp = new Array(n + 1).fill(0);
Expand All @@ -206,7 +207,7 @@ var climbStairs = function(n) {
};
```

TypeScript:
### TypeScript:

```typescript
function climbStairs(n: number): number {
Expand All @@ -226,7 +227,7 @@ function climbStairs(n: number): number {
};
```

Rust:
### Rust:

```rust
impl Solution {
Expand All @@ -250,4 +251,3 @@ impl Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

19 changes: 11 additions & 8 deletions problems/0072.编辑距离.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/),相信结合视频再看本篇题解,更有助于大家对本题的理解**

## 思路

Expand Down Expand Up @@ -227,8 +227,8 @@ public:
## 其他语言版本
### Java:
Java:
```java
public int minDistance(String word1, String word2) {
int m = word1.length();
Expand Down Expand Up @@ -256,7 +256,8 @@ public int minDistance(String word1, String word2) {
}
```

Python:
### Python:

```python
class Solution:
def minDistance(self, word1: str, word2: str) -> int:
Expand All @@ -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)
Expand Down Expand Up @@ -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));
Expand All @@ -338,7 +340,7 @@ const minDistance = (word1, word2) => {
};
```

TypeScript:
### TypeScript:

```typescript
function minDistance(word1: string, word2: string): number {
Expand Down Expand Up @@ -373,7 +375,7 @@ function minDistance(word1: string, word2: string): number {
};
```

C:
### C:


```c
Expand Down Expand Up @@ -405,3 +407,4 @@ int minDistance(char * word1, char * word2){
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>
18 changes: 10 additions & 8 deletions problems/0115.不同的子序列.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public:
## 其他语言版本
### Java:
Java:
```java
class Solution {
public int numDistinct(String s, String t) {
Expand All @@ -182,7 +182,8 @@ class Solution {
}
```

Python:
### Python:

```python
class Solution:
def numDistinct(self, s: str, t: str) -> int:
Expand All @@ -200,7 +201,8 @@ class Solution:
return dp[-1][-1]
```

Python3:
### Python3:

```python
class SolutionDP2:
"""
Expand Down Expand Up @@ -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)
Expand All @@ -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));
Expand All @@ -283,7 +286,7 @@ const numDistinct = (s, t) => {
};
```

TypeScript:
### TypeScript:

```typescript
function numDistinct(s: string, t: string): number {
Expand Down Expand Up @@ -312,9 +315,8 @@ function numDistinct(s: string, t: string): number {
```




<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

22 changes: 10 additions & 12 deletions problems/0121.买卖股票的最佳时机.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
* 输出:0
解释:在这种情况下, 没有交易完成, 所以最大利润为 0。

# 算法公开课

**《代码随想录》算法视频公开课:[动态规划之 LeetCode:121.买卖股票的最佳时机1](https://www.bilibili.com/video/BV1Xe4y1u77q),相信结合视频再看本篇题解,更有助于大家对本题的理解**

## 算法公开课

**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[动态规划之 LeetCode:121.买卖股票的最佳时机1](https://www.bilibili.com/video/BV1Xe4y1u77q),相信结合视频再看本篇题解,更有助于大家对本题的理解**

## 思路

Expand Down Expand Up @@ -202,7 +200,7 @@ public:

## 其他语言版本

Java:
### Java:

> 贪心法:

Expand Down Expand Up @@ -294,8 +292,7 @@ class Solution {
```


Python:
### Python:

> 贪心法:
```python
Expand Down Expand Up @@ -351,7 +348,8 @@ class Solution:
return dp1
```

Go:
### Go:

> 贪心法:
```Go
func maxProfit(prices []int) int {
Expand Down Expand Up @@ -418,7 +416,7 @@ func max(a, b int) int {
}
```

JavaScript:
### JavaScript:

> 动态规划
Expand Down Expand Up @@ -454,7 +452,7 @@ var maxProfit = function(prices) {
};
```

TypeScript:
### TypeScript:

> 贪心法
Expand Down Expand Up @@ -492,7 +490,7 @@ function maxProfit(prices: number[]): number {
};
```

C#:
### C#:

> 贪心法
Expand Down Expand Up @@ -533,7 +531,7 @@ public class Solution
}
```

Rust:
### Rust:

> 贪心
Expand Down
21 changes: 11 additions & 10 deletions problems/0122.买卖股票的最佳时机II(动态规划).md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
* 1 <= prices.length <= 3 * 10 ^ 4
* 0 <= prices[i] <= 10 ^ 4

# 算法公开课
## 算法公开课

**《代码随想录》算法视频公开课:[动态规划,股票问题第二弹 | LeetCode:122.买卖股票的最佳时机II](https://www.bilibili.com/video/BV1D24y1Q7Ls),相信结合视频再看本篇题解,更有助于大家对本题的理解**
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html)[动态规划,股票问题第二弹 | LeetCode:122.买卖股票的最佳时机II](https://www.bilibili.com/video/BV1D24y1Q7Ls),相信结合视频再看本篇题解,更有助于大家对本题的理解**


## 思路
Expand Down Expand Up @@ -133,8 +133,8 @@ public:

## 其他语言版本

### Java:

Java:
```java
// 动态规划
class Solution
Expand Down Expand Up @@ -191,7 +191,7 @@ class Solution {
}
```

Python:
### Python:

> 版本一:
```python
Expand Down Expand Up @@ -221,7 +221,8 @@ class Solution:
return dp[(length-1) % 2][1]
```

Go:
### Go:

```go
// 买卖股票的最佳时机Ⅱ 动态规划
// 时间复杂度:O(n) 空间复杂度:O(n)
Expand Down Expand Up @@ -250,7 +251,8 @@ func max(a, b int) int {
}
```

Javascript:
### JavaScript:

```javascript
// 方法一:动态规划(dp 数组)
const maxProfit = (prices) => {
Expand Down Expand Up @@ -290,7 +292,7 @@ const maxProfit = (prices) => {
}
```

TypeScript:
### TypeScript:

> 动态规划

Expand Down Expand Up @@ -326,7 +328,7 @@ function maxProfit(prices: number[]): number {
};
```

C#:
### C#:

> 贪心法
Expand Down Expand Up @@ -363,7 +365,7 @@ public class Solution
}
```

Rust:
### Rust:

> 贪心
Expand Down Expand Up @@ -414,4 +416,3 @@ impl Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

Loading

0 comments on commit 2691e27

Please sign in to comment.