Ad
  • Custom User Avatar

    That's theory on complexity and if we follow, we should say that what you propose is O(n*m) where m is the number of letters a-z i.e. the size of your boolean array. Now, the log(n) part is less than that for even the largest possible memory of a single computer. And while I agree that m can be considered constant, the O(nlogn) solution will be faster in any practical application. That's theory. And when it comes to other things like readability, then, well the code speaks for itself :)