fork download
  1. import java.io.BufferedReader;
  2. import java.io.PrintWriter;
  3. import java.io.InputStreamReader;
  4.  
  5. class DhapuandHammingDistance
  6. {
  7. public static void main(String arg[])throws Exception
  8. {
  9. PrintWriter pr=new PrintWriter(System.out,true);
  10.  
  11. int t,c,i,l1,l2;
  12. char c1[],c2[];
  13. String s;
  14. t = Integer.parseInt(br.readLine());
  15. while ( t-->0 )
  16. {
  17. s = br.readLine();
  18. //c2 = br.readLine();
  19. c1 = s.toCharArray();
  20. c2 = s.toCharArray();
  21. l1 = c1.length;
  22. l2 = c2.length;
  23. c = 0;
  24. if(l1!=l2)
  25. pr.println(-1);
  26. else
  27. {
  28. for(i=0;i<l1;i++)
  29. {
  30. if(c1[i]!=c2[i])
  31. c++;
  32. }
  33.  
  34. pr.println(c);
  35. }
  36.  
  37. }
  38.  
  39. }
  40.  
  41. }
Success #stdin #stdout 0.11s 320320KB
stdin
2
aba
abb
stdout
0
0