Skip to content

Commit 42023a3

Browse files
committed
[level 2] Title: 올바른 괄호, Time: 18.33 ms, Memory: 54.4 MB -BaekjoonHub
1 parent 37f78ca commit 42023a3

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

프로그래머스/2/12909. 올바른 괄호/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 10.4 MB, 시간: 7.22 ms
7+
메모리: 54.4 MB, 시간: 18.33 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2024년 2월 1일 21:35:25
19+
2025년 05월 28일 18:22:52
2020

2121
### 문제 설명
2222

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
3+
class Solution {
4+
static Stack<Character> stack = new Stack<>();
5+
6+
boolean solution(String s) {
7+
boolean answer = true;
8+
9+
for(int i=0; i<s.length(); i++){
10+
char ch = s.charAt(i);
11+
12+
// '('면 스택에 추가, ')'면 스택이 비어있는지 확인 후 pop
13+
if(ch == '('){
14+
stack.push('(');
15+
}else{
16+
if(stack.isEmpty()){
17+
return false;
18+
}
19+
stack.pop();
20+
}
21+
}
22+
23+
return (stack.isEmpty())? true:false;
24+
}
25+
}

0 commit comments

Comments
 (0)