1
-1

[–] king_of_voat 1 points -1 points (+0|-1) ago 

Seems fairly basic.

First obvious thing is to check for equal length of the two strings in O(1).

If they are equal in lengths you could either sort each of the strings in O(n * log(n)) and then do an element wise comparison of the results. The overall complexity of this approach would be O(n * log(n)).

If you know your alphabet and have a function to convert each Character to an integer you can build an array that has the same size of your Alphabet. I.e. a -> 0, b -> 1, then you could just walk over each of the strings and count the occurrences of each character. Then the whole thing would take O(n). You can't really get it to run faster than that.