https://www.acmicpc.net/problem/3059
3059번: 등장하지 않는 문자의 합
입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터는 한 줄로 구성되어 있고, 문자열 S가 주어진다. S는 알파벳
www.acmicpc.net
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
for (int i = 0; i < N; i++) {
int[] alpha = new int[26];
String s = br.readLine();
for (int j = 0; j < s.length(); j++) {
char c = s.charAt(j);
alpha[c-65]++;
}
int sum = 0;
for (int k = 0; k < alpha.length; k++) {
if (alpha[k] == 0) {
sum += k + 65;
}
}
System.out.println(sum);
}
}
}
'알고리즘 > 백준' 카테고리의 다른 글
백준 11966 2의 제곱인가 (0) | 2022.12.07 |
---|---|
백준 11023 더하기 3 (0) | 2022.12.07 |
백준 1247 부호 (0) | 2022.12.07 |
백준 2857 FBI (0) | 2022.12.07 |
백준 9295 주사위 (0) | 2022.12.07 |