Study📚/백준

[백준] - #1316: 그룹 단어 체커

woo!na 2024. 5. 31. 22:00

문제 출처 : https://www.acmicpc.net/

 


#1316: 그룹 단어 체커 (언어 : Java11)


제출 답안

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int interval = Integer.parseInt(br.readLine());
		int count = 0;
		for(int i=0; i<interval; i++) {
			String word = br.readLine();
			boolean result = true;
			for(int j=0; j<word.length(); j++) {
				String a = word.substring(j, j+1);
				String temp = word.substring(word.indexOf(a), word.lastIndexOf(a)+1);
				temp = temp.replaceAll(a,"");
				if(temp.length()!=0) {
					result = false;
					break;
				}
			}
			if(result)
				count++;
		}
		System.out.println(count);
		br.close();
	}
}

comment

- 리소스 반납 잊지말기~(이미 많이 잊음)

'Study📚 > 백준' 카테고리의 다른 글

[백준] - #10828: 스택  (0) 2024.06.02
[백준] - #2558: A+B - 2  (0) 2024.06.02
[백준] - #9012: 괄호  (0) 2024.05.31
[백준] - #10872: 팩토리얼  (0) 2024.05.30
[백준] - #1978: 소수 찾기  (0) 2024.05.29