We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7f0fada commit a96708aCopy full SHA for a96708a
bona1122/[week2]Stack/Valid_brackets.js
@@ -0,0 +1,10 @@
1
+const solution = (s) => {
2
+ let cnt = 0;
3
+
4
+ for (let i = 0; i < s.length; i++) {
5
+ cnt += s[i] === "(" ? +1 : -1;
6
+ if (cnt < 0) return false;
7
+ }
8
9
+ return cnt === 0;
10
+};
0 commit comments