We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intcounter=0;for(inti=0;i<s1.length();i++){for(intj=0;j<s2.length();j++){if(s1.charAt(i)==s2.charAt(j)){counter++;// Mark characters as used by replacing them with spacess1=s1.substring(0,i)+' '+s1.substring(i+1);s2=s2.substring(0,j)+' '+s2.substring(j+1);break;}}}System.out.println(counter);return(s1.length()-counter)+(s2.length()-counter);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Java 8