We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4fb656c commit 714782aCopy full SHA for 714782a
1 file changed
valid-parentheses/reeseo3o.js
@@ -0,0 +1,20 @@
1
+const isValid = (s) => {
2
+ const stack = [];
3
+ const map = {
4
+ "(": ")",
5
+ "[": "]",
6
+ "{": "}"
7
+ };
8
+
9
+ for (const char of s) {
10
+ if (map[char]) {
11
+ console.log(char);
12
+ stack.push(char);
13
+ } else {
14
+ if (stack.length === 0 || map[stack.pop()] !== char) {
15
+ return false;
16
+ }
17
18
19
+ return stack.length === 0;
20
+}
0 commit comments