Ad
  • Default User Avatar

    Anyway, thinking about it a little bit, considering random strings of English characters, if a character is repeated then on average you'll have to check 26 characters working backwards from the end of the string before you find a repeated instance of it. So unless you're working against a malevolent entity who is using all the unicode characters against you, a solution that uses indexOf and skips characters it already found dupes of is probably best. But this was fun as an exercise.

  • Default User Avatar

    Aw man, I just realised I have an indexOf inside a loop. That's immediately O(n^2) D: