Skip to content

Commit 1141943

Browse files
authored
Update README_EN.md
1 parent 52b4945 commit 1141943

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

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

+14-13
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,22 @@ impl Solution {
232232

233233
### **C#**
234234

235-
```C#
235+
```cs
236236
public class Solution {
237237
public bool IsValid(string s) {
238-
Stack<char> ch = new Stack<char>();
239-
foreach (var item in s.ToCharArray())
240-
if (item == '(')
241-
ch.Push(')');
242-
else if (item == '[')
243-
ch.Push(']');
244-
else if (item == '{')
245-
ch.Push('}');
246-
else if (ch.Count == 0 || ch.Pop() != item)
247-
return false;
248-
249-
return ch.Count == 0;
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;
250251
}
251252
}
252253
```

0 commit comments

Comments
 (0)