Skip to content

Commit

Permalink
B_10799
Browse files Browse the repository at this point in the history
  • Loading branch information
likppi10 committed Oct 24, 2021
1 parent 0a8b33f commit cbfd0e2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Algorithm_Baek/Basic/B_201/B_10799_쇠막대기.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package B_201_자료구조1연습;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class B_10799_쇠막대기 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

char[] I = br.readLine().toCharArray();
int st = 0;
int res = 0;

for(int i=0; i<I.length; i++) {
if(I[i] == '(') {
if(i<I.length-1) {
if(I[i+1] == ')') {
res += st;
i++;
}else st++;
}else st++;
}else if(I[i] == ')') {
res++;
st--;
}
}

System.out.println(res);
}
}

0 comments on commit cbfd0e2

Please sign in to comment.