Skip to content

Commit 1e2f2b0

Browse files
committed
valid parentheses / 중급
1 parent 3654602 commit 1e2f2b0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function solution(s) {
2+
const stack = [];
3+
for (const c of s) {
4+
if (c === "(") {
5+
stack.push(c);
6+
} else if (c === ")") {
7+
if (stack.length === 0) {
8+
continue;
9+
} else {
10+
stack.pop();
11+
}
12+
}
13+
}
14+
15+
return stack.length === 0;
16+
}

0 commit comments

Comments
 (0)