First, of all n log n seems to be the fastest algorithm if we don’t use additional data structures, but I wonder if this impementation on n would make sense:
- Create array of 26 empty elements (or the initial value of each element could be anything out of lowercase a-z range)
- create an map of sorted alphabet (i.e, a->0, b->1, etc).
- Loop through the letters in the isogram and place each letter in the array element corresponding to alpahbetical order (example: bad b goes to 1, a goes to 0, d goes to 3).
- If when placing a letter, the place in the array is already “occupied”, this is not an isogram.
Would this be considered a sort of n + (array and map creation logic) operation, and thus closer to n?