Skip to content

Commit aa88a14

Browse files
committed
Feat: 배열, 연결 리스트, 스택, 큐_올바른 괄호(레벨2)
효율성 테스트 - 시간 초과
1 parent 676a453 commit aa88a14

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Diff for: 1주차/정혜연/레벨2__올바른_괄호.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function solution(s) {
2+
const arr = [];
3+
4+
for (let i in s) {
5+
if (s[i] === "(") {
6+
arr.push(s[i]);
7+
} else {
8+
if (arr[arr.length - 1] === "(") {
9+
arr.pop();
10+
} else {
11+
return false;
12+
}
13+
}
14+
}
15+
16+
return arr.length === 0 ? true : false;
17+
}

0 commit comments

Comments
 (0)