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.
staticbooleanisAnagram(Stringa,Stringb){// Complete the functiona=a.toLowerCase();b=b.toLowerCase();int[]counts_a=newint[27];int[]counts_b=newint[27];for(inti=0;i<a.length();i++)counts_a[a.charAt(i)-'a']+=1;for(inti=0;i<b.length();i++)counts_b[b.charAt(i)-'a']+=1;if(a.length()!=b.length())returnfalse;for(inti=0;i<a.length();i++){if(counts_a[a.charAt(i)-'a']!=counts_b[a.charAt(i)-'a']){returnfalse;}}returntrue;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Anagrams
You are viewing a single comment's thread. Return to all comments →