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

Commit e6b208a

Browse files
Merge pull request youngyangyang04#2194 from jinbudaily/master
更新 双指针总结、栈与队列篇章 排版格式修复
2 parents fc2a54a + 5d76e86 commit e6b208a

10 files changed

+161
-129
lines changed

‎problems/0020.有效的括号.md‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@
3939
* 输入: "{[]}"
4040
* 输出: true
4141

42-
#思路
42+
## 算法公开课
4343

44-
《代码随想录》算法视频公开课:[栈的拿手好戏!| LeetCode:20. 有效的括号](https://www.bilibili.com/video/BV1AF411w78g),相信结合视频在看本篇题解,更有助于大家对链表的理解
44+
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[栈的拿手好戏!| LeetCode:20. 有效的括号](https://www.bilibili.com/video/BV1AF411w78g),相信结合视频再看本篇题解,更有助于大家对本题的理解**
4545

46+
## 思路
4647

47-
## 题外话
48+
### 题外话
4849

4950
**括号匹配是使用栈解决的经典问题。**
5051

@@ -68,7 +69,7 @@ cd a/b/c/../../
6869

6970
这里我就不过多展开了,先来看题。
7071

71-
## 进入正题
72+
### 进入正题
7273

7374
由于栈结构的特殊性,非常适合做对称匹配类的题目。
7475

@@ -143,8 +144,8 @@ public:
143144
144145
## 其他语言版本
145146
147+
### Java:
146148
147-
Java:
148149
```Java
149150
class Solution {
150151
public boolean isValid(String s) {
@@ -171,7 +172,8 @@ class Solution {
171172
}
172173
```
173174

174-
Python:
175+
### Python:
176+
175177
```python
176178
# 方法一,仅使用栈,更省空间
177179
class Solution:
@@ -213,7 +215,8 @@ class Solution:
213215
return True if not stack else False
214216
```
215217

216-
Go:
218+
### Go:
219+
217220
```Go
218221
func isValid(s string) bool {
219222
hash := map[byte]byte{')':'(', ']':'[', '}':'{'}
@@ -235,7 +238,8 @@ func isValid(s string) bool {
235238
}
236239
```
237240

238-
Ruby:
241+
### Ruby:
242+
239243
```ruby
240244
def is_valid(strs)
241245
symbol_map = {')' => '(', '}' => '{', ']' => '['}
@@ -253,7 +257,8 @@ def is_valid(strs)
253257
end
254258
```
255259

256-
Javascript:
260+
### Javascript:
261+
257262
```javascript
258263
var isValid = function (s) {
259264
const stack = [];
@@ -296,7 +301,7 @@ var isValid = function(s) {
296301
};
297302
```
298303

299-
TypeScript:
304+
### TypeScript:
300305

301306
版本一:普通版
302307

@@ -348,7 +353,7 @@ function isValid(s: string): boolean {
348353
};
349354
```
350355

351-
Swift
356+
### Swift:
352357

353358
```swift
354359
func isValid(_ s: String) -> Bool {
@@ -373,7 +378,8 @@ func isValid(_ s: String) -> Bool {
373378
}
374379
```
375380

376-
C:
381+
### C:
382+
377383
```C
378384
//辅助函数:判断栈顶元素与输入的括号是否为一对。若不是,则返回False
379385
int notMatch(char par, char* stack, int stackTop) {
@@ -414,8 +420,8 @@ bool isValid(char * s){
414420
}
415421
```
416422
423+
### C#:
417424
418-
C#:
419425
```csharp
420426
public class Solution {
421427
public bool IsValid(string s) {
@@ -447,7 +453,8 @@ public class Solution {
447453
}
448454
```
449455

450-
PHP:
456+
### PHP:
457+
451458
```php
452459
// https://www.php.net/manual/zh/class.splstack.php
453460
class Solution
@@ -475,8 +482,8 @@ class Solution
475482
}
476483
```
477484

485+
### Scala:
478486

479-
Scala:
480487
```scala
481488
object Solution {
482489
import scala.collection.mutable
@@ -499,7 +506,7 @@ object Solution {
499506
}
500507
```
501508

502-
rust:
509+
### Rust:
503510

504511
```rust
505512
impl Solution {

‎problems/0150.逆波兰表达式求值.md‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
<p align="center"><strong><a href="https://mp.weixin.qq.com/s/tqCxrMEU-ajQumL1i8im9A">参与本项目</a>,贡献其他语言版本的代码,拥抱开源,让更多学习算法的小伙伴们收益!</strong></p>
66

77

8-
9-
108
> 这不仅仅是一道好题,也展现出计算机的思考方式
119
1210
# 150. 逆波兰表达式求值
@@ -63,9 +61,13 @@
6361

6462
* 适合用栈操作运算:遇到数字则入栈;遇到运算符则取出栈顶两个数字进行计算,并将结果压入栈中。
6563

66-
# 思路
64+
## 算法公开课
65+
66+
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[栈的最后表演! | LeetCode:150. 逆波兰表达式求值](https://www.bilibili.com/video/BV1kd4y1o7on),相信结合视频再看本篇题解,更有助于大家对本题的理解**
6767

68-
《代码随想录》算法视频公开课:[栈的最后表演! | LeetCode:150. 逆波兰表达式求值](https://www.bilibili.com/video/BV1kd4y1o7on),相信结合视频再看本篇题解,更有助于大家对本题的理解。
68+
## 思路
69+
70+
### 正题
6971

7072
在上一篇文章中[1047.删除字符串中的所有相邻重复项](https://programmercarl.com/1047.删除字符串中的所有相邻重复项.html)提到了 递归就是用栈来实现的。
7173

@@ -117,7 +119,7 @@ public:
117119
* 空间复杂度: O(n)
118120

119121

120-
## 题外话
122+
### 题外话
121123

122124
我们习惯看到的表达式都是中缀表达式,因为符合我们的习惯,但是中缀表达式对于计算机来说就不是很友好了。
123125

@@ -134,11 +136,9 @@ public:
134136
> During the 1970s and 1980s, Hewlett-Packard used RPN in all of their desktop and hand-held calculators, and continued to use it in some models into the 2020s.
135137
136138

137-
138-
139139
## 其他语言版本
140140

141-
java:
141+
### Java:
142142

143143
```Java
144144
class Solution {
@@ -164,7 +164,7 @@ class Solution {
164164
}
165165
```
166166

167-
python3
167+
### Python3:
168168

169169
```python
170170
from operator import add, sub, mul
@@ -201,7 +201,8 @@ class Solution:
201201

202202
```
203203

204-
Go:
204+
### Go:
205+
205206
```Go
206207
func evalRPN(tokens []string) int {
207208
stack := []int{}
@@ -228,7 +229,7 @@ func evalRPN(tokens []string) int {
228229
}
229230
```
230231

231-
javaScript:
232+
### JavaScript:
232233

233234
```js
234235
var evalRPN = function (tokens) {
@@ -259,7 +260,7 @@ var evalRPN = function (tokens) {
259260
};
260261
```
261262

262-
TypeScript:
263+
### TypeScript:
263264

264265
普通版:
265266

@@ -324,7 +325,8 @@ function evalRPN(tokens: string[]): number {
324325
};
325326
```
326327

327-
Swift:
328+
### Swift:
329+
328330
```Swift
329331
func evalRPN(_ tokens: [String]) -> Int {
330332
var stack = [Int]()
@@ -357,7 +359,8 @@ func evalRPN(_ tokens: [String]) -> Int {
357359
}
358360
```
359361

360-
C#:
362+
### C#:
363+
361364
```csharp
362365
public int EvalRPN(string[] tokens) {
363366
int num;
@@ -391,8 +394,8 @@ public int EvalRPN(string[] tokens) {
391394
}
392395
```
393396

397+
### PHP:
394398

395-
PHP:
396399
```php
397400
class Solution {
398401
function evalRPN($tokens) {
@@ -417,7 +420,8 @@ class Solution {
417420
}
418421
```
419422

420-
Scala:
423+
### Scala:
424+
421425
```scala
422426
object Solution {
423427
import scala.collection.mutable
@@ -447,7 +451,7 @@ object Solution {
447451
}
448452
```
449453

450-
rust:
454+
### Rust:
451455

452456
```rust
453457
impl Solution {

0 commit comments

Comments
(0)

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