Ad
  • Custom User Avatar

    As was mentioned above, try using some datastructure that has something like a hash table for lookups of possible solutions. Something like a dictionary in Python, an associative array in PHP, a map in Elixir, etc.

  • Custom User Avatar

    Search rather on the side of a useful data container to store/retrieve useful informations. ;)

  • Custom User Avatar

    2 loops, that's O(n^2). You need a O(n) solution, with a single loop.