D3 - 8821. 적고 지우기
문제출처: https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AW37UDPKCgQDFATy&categoryId=AW37UDPKCgQDFATy&categoryType=CODE
순서대로 숫자를 읽어 쓰여져 있을지를 확인하여 해결한 문제
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
class Solution
{
static boolean[] isWritten = new boolean[10];
public static void main(String args[]) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for(int test_case = 1; test_case <= T; test_case++)
{
Arrays.fill(isWritten, false);
String numbers = br.readLine();
for (int i = 0; i < numbers.length(); i++) {
int num = (numbers.charAt(i)) - '0';
isWritten[num] = !isWritten[num];
}
int count = 0;
for (boolean b : isWritten) {
if (b) count++;
}
System.out.println("#"+test_case+" "+count);
}
br.close();
}
}