Skip to content

Commit a96708a

Browse files
committed
Valid brackets / 중급
1 parent 7f0fada commit a96708a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)