Ad
  • Custom User Avatar

    There is not much point fitting it all onto one line just because you can. It just makes your code harder to understand.

  • Custom User Avatar

    A minor optimisation could be to set j = i + 1, as to avoid some repeated comparisons, otherwise it looks good

  • Custom User Avatar

    Not every problem needs a hash table. The simplest solution is only 5 lines and it also just so happens to be the most intuitive and readable solution. Respect for the hash table implementation though!

  • Custom User Avatar

    Ignore the comments at the top haha. Was planning something else then forgot to delete them.

  • Custom User Avatar

    It should be more clear that the interval [x, y] includes x, but not y. If you think of the problem in terms of sets, the set of the interval [x, y] = {x, x + 1, x + 2, ... , y - 2, y - 1}. Please correct me if I'm wrong.