J.P. Morgan Interview Question

Is this word an anagram

Interview Answer

Anonymous

Oct 16, 2024

A good approach would be to sort the characters of the words and then compare. (Be sure to have an edge case where if the lengths do not match or if any or both of the Strings are empty/null then exit). Better approach would be to have an ASCII charset where characters of the 1st String ++ the charset array and characters of the second string - - the array. Finally iterate through the array and return false if any of the elements is not 0.