File tree Expand file tree Collapse file tree 1 file changed +1
-27
lines changed Expand file tree Collapse file tree 1 file changed +1
-27
lines changed Original file line number Diff line number Diff line change @@ -85,32 +85,6 @@ char leftOf(char c) {
85
85
86
86
![ labuladong] ( ../pictures/labuladong.jpg )
87
87
88
- [ labuladong] ( https://github.com/labuladong ) 提供 C++ 解法代码:
89
-
90
- ``` cpp
91
- bool isValid (string str) {
92
- stack<char > left;
93
- for (char c : str) {
94
- if (c == '(' || c == '{' || c == '[ ')
95
- left.push(c);
96
- else // 字符 c 是右括号
97
- if (!left.empty() && leftOf(c) == left.top())
98
- left.pop();
99
- else
100
- // 和最近的左括号不匹配
101
- return false;
102
- }
103
- // 是否所有的左括号都被匹配了
104
- return left.empty();
105
- }
106
-
107
- char leftOf(char c) {
108
- if (c == '}') return '{';
109
- if (c == ')') return '(';
110
- return '[ ';
111
- }
112
- ```
113
-
114
88
[ 张三] ( any_link_you_want ) 提供 Java 代码:
115
89
116
90
``` java
@@ -135,4 +109,4 @@ def isValid(str):
135
109
136
110
[ 下一篇:如何寻找消失的元素] ( ../高频面试系列/消失的元素.md )
137
111
138
- [ 目录] ( ../README.md#目录 )
112
+ [ 目录] ( ../README.md#目录 )
You can’t perform that action at this time.
0 commit comments