코테 연습 with Java - 2

아이모·2022년 10월 28일
0

코테

목록 보기
8/15

swea 14555 공과 잡초

for(int test_case = 1; test_case <= T; test_case++)
		{
            int result = 0;
            Stack bracketStack = new Stack<String>();
            String pasture = sc.next();
            boolean bracket = false;
            for(int i = 0; i < pasture.length(); i++){
                if(i < pasture.length()-1){
                	if(pasture.substring(i, i+2).equals("()") || pasture.substring(i, i+2).equals("(|") || pasture.substring(i, i+2).equals("|)"))
                    	result++;
                }
            }
            System.out.println("#"+test_case+" "+ result);
		}        
profile
데이터로 보는 실력

0개의 댓글