Isogram with Hashtable, time complexity O(n)

The Fastest way I can think about checking whether a word is an isogram is to use hashtable. Then the time complexity can drop to O(n). But we need to create an array with 26 elements with initializing to 0. But this space trade-off is negligible comparing to the First sort then, iterate adjacent word list. Basically time complexity of many classical algorithms involving in data comparison can be improved by introducing some abstract data structures. Most common data structures will be used to improve the time complexity are hashtable, graph, tree, stack, queue and heap. But in most cases, there is always a trade-off between time complexity and space complexity.

Privacy & Terms