fork download
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. public class Main {
  4. public static void main (String[] args) throws Exception{
  5. final int ABC_SIZE = 26;
  6. int n = Integer.parseInt(br.readLine());
  7. for (int i = 0; i < n; i++) {
  8. int[] counters = new int[ABC_SIZE];
  9. String firstWord = br.readLine();
  10. for (int j = 0; j < firstWord.length(); j++) {
  11. counters[firstWord.charAt(j) - 'a']++;
  12. }
  13. String secondWord = br.readLine();
  14. for (int j = 0; j < secondWord.length(); j++) {
  15. counters[secondWord.charAt(j) - 'a']--;
  16. }
  17. int matchingLetters = 0;
  18. for (int k = 0; k < ABC_SIZE; k++) {
  19. matchingLetters += Math.abs(counters[k]);
  20. }
  21. System.out.println("Case #" + (i + 1) + ": " + matchingLetters);
  22. }
  23.  
  24. }
  25. }
Success #stdin #stdout 0.04s 2184192KB
stdin
1
memory
moratory

stdout
Case #1:  6