Skip to content

Commit 8fe78a3

Browse files
authored
docs: update README_EN and README to lc problem: No.0020 (#1930)
1 parent 62a57f8 commit 8fe78a3

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

solution/0000-0099/0020.Valid Parentheses/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,28 @@ impl Solution {
252252
}
253253
```
254254

255+
### **C#**
256+
257+
```cs
258+
public class Solution {
259+
public bool IsValid(string s) {
260+
Stack<char> stk = new Stack<char>();
261+
foreach (var c in s.ToCharArray()) {
262+
if (c == '(') {
263+
stk.Push(')');
264+
} else if (c == '[') {
265+
stk.Push(']');
266+
} else if (c == '{') {
267+
stk.Push('}');
268+
} else if (stk.Count == 0 || stk.Pop() != c) {
269+
return false;
270+
}
271+
}
272+
return stk.Count == 0;
273+
}
274+
}
275+
```
276+
255277
### **...**
256278

257279
```

solution/0000-0099/0020.Valid Parentheses/README_EN.md

+22
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@ impl Solution {
230230
}
231231
```
232232

233+
### **C#**
234+
235+
```cs
236+
public class Solution {
237+
public bool IsValid(string s) {
238+
Stack<char> stk = new Stack<char>();
239+
foreach (var c in s.ToCharArray()) {
240+
if (c == '(') {
241+
stk.Push(')');
242+
} else if (c == '[') {
243+
stk.Push(']');
244+
} else if (c == '{') {
245+
stk.Push('}');
246+
} else if (stk.Count == 0 || stk.Pop() != c) {
247+
return false;
248+
}
249+
}
250+
return stk.Count == 0;
251+
}
252+
}
253+
```
254+
233255
### **...**
234256

235257
```

0 commit comments

Comments
 (0)