You are viewing a single comment's thread. Return to all comments →
int diff = 0,t; t = s.nextInt(); String str = s.next(); int len = str.length(); for(int k = 0; k < t;k++) { if(len%2!=0) System.out.println("-1"); else { String str1 = str.substring(0,(len/2)); String str2 = str.substring(len/2); for(int i=0;i<str1.length();i++) { if(!str2.contains(str1.charAt(i)+"")) diff++; } System.out.println(diff); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
You are viewing a single comment's thread. Return to all comments →