728x90
https://www.acmicpc.net/problem/1919
문제 풀이
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
char[] c1 = br.readLine().toCharArray(), c2 = br.readLine().toCharArray();
br.close();
int[] a1 = new int[26], a2 = new int[26];
for (char c : c1) a1[c - 'a']++;
for (char c : c2) a2[c - 'a']++;
int ans = 0, n1, n2, i;
for (i = 0; i < 26; ++i) {
n1 = a1[i]; n2 = a2[i];
if (n1 == n2) continue;
ans += Math.max(n1, n2) - Math.min(n1, n2);
}
System.out.println(ans);
}
}
반응형
'코딩 문제 풀기 ( Algorithm problem solving ) > 백준 온라인 저지 ( BOJ )' 카테고리의 다른 글
[백준(Baekjoon)][자바(java)] 11080 : Almost an Anagram (0) | 2021.11.08 |
---|---|
[백준(Baekjoon)][자바(java)] 7587 : Anagram (0) | 2021.11.07 |
[백준(Baekjoon)][자바(java)] 6996 : 애너그램 (0) | 2021.11.06 |
[백준(Baekjoon)][자바(java)] 2578 : 빙고 (0) | 2021.11.06 |
[백준(Baekjoon)][자바(java)] 15666 : N과 M (12) / 백트래킹 (0) | 2021.09.02 |