Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 17 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e5d694d
Update
youngyangyang04 Jul 19, 2023
9b3c234
Merge branch 'master' of github.com:youngyangyang04/leetcode-master
youngyangyang04 Jul 19, 2023
b3d1a88
Update 0503.下一个更大元素II.md
Ainevsia Jul 8, 2023
f3f549d
Update 0042.接雨水.md
Ainevsia Jul 8, 2023
7aa2a3e
Update 0084.柱状图中最大的矩形.md
Ainevsia Jul 9, 2023
0dc6bb5
添加59.螺旋矩阵II Ruby实现
niuli1991 Jul 25, 2023
7c9fcfe
更新 时间复杂度 O(n)超时 拍版格式修复
jinbudaily Jul 27, 2023
e0c5da7
更新 单调栈系列题目 排版格式修复
jinbudaily Jul 27, 2023
dc9fb7c
更新 数组额外题目 排版格式修复
jinbudaily Jul 27, 2023
56f3780
更新 哈希表额外题目 排版格式修复
jinbudaily Jul 27, 2023
bbb2a60
更新 二叉树额外题目 排版格式修复
jinbudaily Jul 27, 2023
e9b0d46
更新 贪心与动态规划 额外题目 排版格式修复
jinbudaily Jul 27, 2023
a5eb340
更新 图论 并查集 模拟 位运算 额外题目 排版格式修复
jinbudaily Jul 27, 2023
e7c1224
合并修改 0503.下一个更大元素II
jinbudaily Jul 27, 2023
9693ad4
Update
youngyangyang04 Jul 27, 2023
4037eb6
Merge branch 'master' of github.com:youngyangyang04/leetcode-master
youngyangyang04 Jul 27, 2023
4f632c8
Merge pull request #2211 from jinbudaily/master
youngyangyang04 Jul 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
更新 贪心与动态规划 额外题目 排版格式修复
  • Loading branch information
jinbudaily committed Jul 27, 2023
commit e9b0d46f3535546063192c170606bffa8ff75a32
23 changes: 12 additions & 11 deletions problems/0005.最长回文子串.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
* 输出:"a"


# 思路
## 思路

本题和[647.回文子串](https://programmercarl.com/0647.回文子串.html) 差不多是一样的,但647.回文子串更基本一点,建议可以先做647.回文子串

## 暴力解法
### 暴力解法

两层for循环,遍历区间起始位置和终止位置,然后判断这个区间是不是回文。

时间复杂度:O(n^3)

## 动态规划
### 动态规划

动规五部曲:

Expand Down Expand Up @@ -208,7 +208,7 @@ public:
* 时间复杂度:O(n^2)
* 空间复杂度:O(n^2)

## 双指针
### 双指针

动态规划的空间复杂度是偏高的,我们再看一下双指针法。

Expand Down Expand Up @@ -258,9 +258,9 @@ public:



# 其他语言版本
## 其他语言版本

Java:
### Java:

```java
// 双指针 动态规划
Expand Down Expand Up @@ -327,7 +327,7 @@ class Solution {
}
```

Python:
### Python:

```python
class Solution:
Expand Down Expand Up @@ -377,7 +377,7 @@ class Solution:
return s[start:end]

```
Go:
### Go:

```go
func longestPalindrome(s string) string {
Expand Down Expand Up @@ -411,7 +411,7 @@ func longestPalindrome(s string) string {

```

JavaScript:
### JavaScript:

```js
//动态规划解法
Expand Down Expand Up @@ -527,7 +527,7 @@ var longestPalindrome = function(s) {
};
```

C:
### C:

动态规划:
```c
Expand Down Expand Up @@ -615,7 +615,7 @@ char * longestPalindrome(char * s){
}
```

C#:
### C#:

動態規則:
```c#
Expand Down Expand Up @@ -681,3 +681,4 @@ public class Solution {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

13 changes: 7 additions & 6 deletions problems/0132.分割回文串II.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* 1 <= s.length <= 2000
* s 仅由小写英文字母组成

# 思路
## 思路

我们在讲解回溯法系列的时候,讲过了这道题目[回溯算法:131.分割回文串](https://programmercarl.com/0131.分割回文串.html)。

Expand Down Expand Up @@ -201,9 +201,9 @@ public:
```


# 其他语言版本
## 其他语言版本

## Java
### Java

```java
class Solution {
Expand Down Expand Up @@ -257,7 +257,7 @@ class Solution {
}
```

## Python
### Python

```python
class Solution:
Expand Down Expand Up @@ -286,7 +286,7 @@ class Solution:
return dp[-1]
```

## Go
### Go

```go
func minCut(s string) int {
Expand Down Expand Up @@ -330,7 +330,7 @@ func min(i, j int) int {
}
```

## JavaScript
### JavaScript

```js
var minCut = function(s) {
Expand Down Expand Up @@ -376,3 +376,4 @@ var minCut = function(s) {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

17 changes: 9 additions & 8 deletions problems/0649.Dota2参议院.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Dota2 参议院由来自两派的参议员组成。现在参议院希望对一
因此在第二轮只剩下第三个参议员拥有投票的权利,于是他可以宣布胜利。


# 思路
## 思路

这道题 题意太绕了,我举一个更形象的例子给大家捋顺一下。

Expand Down Expand Up @@ -70,7 +70,7 @@ Dota2 参议院由来自两派的参议员组成。现在参议院希望对一

如果对贪心算法理论基础还不了解的话,可以看看这篇:[关于贪心算法,你该了解这些!](https://programmercarl.com/贪心算法理论基础.html) ,相信看完之后对贪心就有基本的了解了。

# 代码实现
## 代码实现

实现代码,在每一轮循环的过程中,去过模拟优先消灭身后的对手,其实是比较麻烦的。

Expand Down Expand Up @@ -111,9 +111,9 @@ public:



# 其他语言版本
## 其他语言版本

## Java
### Java

```java
class Solution {
Expand Down Expand Up @@ -145,7 +145,7 @@ class Solution {
}
```

## Python
### Python

```python
class Solution:
Expand Down Expand Up @@ -173,7 +173,7 @@ class Solution:
return "Radiant" if R else "Dire"
```

## Go
### Go

```go

Expand Down Expand Up @@ -214,7 +214,7 @@ func predictPartyVictory(senateStr string) string {
}
```

## JavaScript
### JavaScript

```js
var predictPartyVictory = function(senateStr) {
Expand Down Expand Up @@ -244,7 +244,7 @@ var predictPartyVictory = function(senateStr) {
};
```

## TypeScript
### TypeScript

```typescript
function predictPartyVictory(senate: string): string {
Expand Down Expand Up @@ -287,3 +287,4 @@ function predictPartyVictory(senate: string): string {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

13 changes: 7 additions & 6 deletions problems/0673.最长递增子序列的个数.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* 解释: 最长递增子序列的长度是1,并且存在5个子序列的长度为1,因此输出5。


# 思路
## 思路

这道题可以说是 [300.最长上升子序列](https://programmercarl.com/0300.最长上升子序列.html) 的进阶版本

Expand Down Expand Up @@ -221,9 +221,9 @@ public:

还有O(nlog n)的解法,使用树状数组,今天有点忙就先不写了,感兴趣的同学可以自行学习一下,这里有我之前写的树状数组系列博客:https://blog.csdn.net/youngyangyang04/category_871105.html (十年前的陈年老文了)

# 其他语言版本
## 其他语言版本

## Java
### Java

```java
class Solution {
Expand Down Expand Up @@ -257,7 +257,7 @@ class Solution {
}
```

## Python
### Python

```python
class Solution:
Expand Down Expand Up @@ -286,7 +286,7 @@ class Solution:
return result;
```

## Go
### Go

```go

Expand Down Expand Up @@ -332,7 +332,7 @@ func findNumberOfLIS(nums []int) int {
}
```

## JavaScript
### JavaScript

```js
var findNumberOfLIS = function(nums) {
Expand Down Expand Up @@ -364,3 +364,4 @@ var findNumberOfLIS = function(nums) {
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
</a>

AltStyle によって変換されたページ (->オリジナル) /