My vote goes to O(n log n + (n-1))

O(n) is simplest on a graph and would be quickest but I’m not sure I can think of code that would achieve it as a result.

I have one idea which is to create an integer array with 26 indexes - one for each letter of the alphabet. The code would increment the corresponding index every time its letter appeared in the word and, if any index was raised higher than 1, the isogram check would return false.

I don’t immediately know how to check if this would fit O(n) or something completely different so I stand by my original answer.

Privacy & Terms