-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_16815.java
More file actions
29 lines (24 loc) · 838 Bytes
/
Copy pathBOJ_16815.java
File metadata and controls
29 lines (24 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// BOJ - 16815
// Problem Sheet - https://www.acmicpc.net/problem/16815
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
Stack<Character> openParen = new Stack<>(); // 여는 괄호를 저장하는 stack
String inputStr = bf.readLine();
for(int i=0 ; i<inputStr.length() ; i++) {
char paren = inputStr.charAt(i);
if(paren == '(') {
openParen.add(paren);
} else if(paren == ')') {
openParen.pop();
} else { // '*'를 만난 경우
break;
}
}
System.out.println(openParen.size());
bf.close();
System.exit(0);
}
}