更新 0516.最长回文子序列 0647.回文子串 动态规划总结 排版格式修复

This commit is contained in:
jinbudaily
2023-07-26 16:25:35 +08:00
parent a0edc60d1f
commit 4760924db0
3 changed files with 20 additions and 15 deletions

View File

@ -152,8 +152,7 @@ public:
## 其他语言版本
Java
### Java
```java
public class Solution {
@ -175,8 +174,7 @@ public class Solution {
}
```
Python
### Python
```python
class Solution:
@ -193,7 +191,7 @@ class Solution:
return dp[0][-1]
```
Go
### Go
```Go
func longestPalindromeSubseq(s string) int {
@ -222,7 +220,7 @@ func longestPalindromeSubseq(s string) int {
}
```
Javascript
### Javascript
```javascript
const longestPalindromeSubseq = (s) => {
@ -247,7 +245,7 @@ const longestPalindromeSubseq = (s) => {
};
```
TypeScript
### TypeScript
```typescript
function longestPalindromeSubseq(s: string): number {
@ -281,3 +279,4 @@ function longestPalindromeSubseq(s: string): number {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

View File

@ -26,11 +26,13 @@
提示:输入的字符串长度不会超过 1000 。
## 暴力解法
## 思路
### 暴力解法
两层for循环遍历区间起始位置和终止位置然后还需要一层遍历判断这个区间是不是回文。所以时间复杂度O(n^3)
## 动态规划
### 动态规划
动规五部曲:
@ -187,7 +189,7 @@ public:
* 时间复杂度O(n^2)
* 空间复杂度O(n^2)
## 双指针法
### 双指针法
动态规划的空间复杂度是偏高的,我们再看一下双指针法。
@ -231,7 +233,7 @@ public:
## 其他语言版本
Java
### Java
动态规划:
@ -337,7 +339,7 @@ class Solution {
}
```
Python
### Python
> 动态规划:
```python
@ -390,7 +392,8 @@ class Solution:
return res
```
Go
### Go
```Go
func countSubstrings(s string) int {
res:=0
@ -416,7 +419,8 @@ func countSubstrings(s string) int {
}
```
Javascript
### Javascript
> 动态规划
```javascript
const countSubstrings = (s) => {
@ -462,7 +466,7 @@ const countSubstrings = (s) => {
}
```
TypeScript
### TypeScript
> 动态规划:
@ -524,3 +528,4 @@ function expandRange(s: string, left: number, right: number): number {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

View File

@ -136,3 +136,4 @@
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>