Ad
  • Default User Avatar

    This is not true with every object. More - an alphabet may contain more or less symbols than latin alphabet. There is no hints in the task that it is latin alphabet. That is why solution O(1) does not exist. Best complexity is O(n) where n is the size of the alphabet. I belive that you need О(n) memory for that complexity. This solution complexity is О(n^2).

  • Default User Avatar

    Wrong: len is O(1), since the length is stored as a property in any object.

  • Custom User Avatar

    @garborg, return len(string) > 26 will be O(n) for only some of the test cases, but not all.
    At best, it is an incomplete solution, right?

  • Default User Avatar

    I believe that no one can do it with O(1). The best possible solution O(n) where n is all possible symbols in an alphabet.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    True about O(n^2). What is the O(1) version?