Voting for isogram checking method

I am going to vote n log n.
However, I’m not entirely sure what would be considered steps and what wouldn’t. In a process such as counting letters and checking for doubles each time sounds like a very efficient method, but it still requires a second check for every letter counted until a duplicate is reached. So it’s efficiency could vary depending on how far down the line the duplicate letter is found.

I would agree with you about n log n. The process of sorting the letters is what would take the longest. Most sorting algorithms have an average time complexity (and a worst case time complexity) of n log n. While it is true that it would take a little longer to check for duplicates in an isogram (where there are no duplicates) compared to a word with duplicates, the sorting process would still dominate the algorithm’s complexity so you don’t need to consider it.

Thanks Lindsay. That’s it. I’d like to see a comparison to see which is actually better.

Privacy & Terms