You are viewing a single comment's thread. Return to all comments →
char[] aArray = a.ToCharArray(); char[] bArray = b.ToCharArray(); Array.Sort(aArray); Array.Sort(bArray); int i = 0, j = 0; int count = 0; while (i < aArray.Length && j < bArray.Length) { if (aArray[i] == bArray[j]) { i++; j++; } else if (aArray[i] < bArray[j]) { i++; count++; } else { j++; count++; } } if(i < aArray.Length) { count += aArray.Length - i; } if(j < bArray.Length) { count += bArray.Length - j; } 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 →