You are viewing a single comment's thread. Return to all comments →
Donot use toCharArray() it takes O(n), so better use charAt(i): My Solution
int [] missingtracker = new int[26]; if(first.equals(second)) return 0; else{ for(int i=0;i<first.length();i++) missingtracker[first.charAt(i) - (int)'a']--; for(int j=0;j<second.length();j++) missingtracker[second.charAt(j)- (int)'a']++; int count=0; for (int i : missingtracker) { count+=Math.abs(i); } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Donot use toCharArray() it takes O(n), so better use charAt(i): My Solution