Ad
  • Custom User Avatar

    As a more focused hint, look up the most common data structures implemented in your language of choice. A few of them can help you.

  • Custom User Avatar

    No worries, samiamahwash! Sorry to have assumed this. As eptaceps mentioned, look for "algorithm complexity". In short, some algorithms are faster than others to accomplish the same task. We usually use this big-O notation to describe how a certain algorithm scales with its input. O(N^2) mean that the calculations done by the algorithm scale with the square of its input size (or whichever other property natural to the problem). This is worse than a O(N) algorithm, which does a lot less work and hence is notably faster for large inputs.

  • Default User Avatar

    samiamahwash search for "algorithm complexity"

  • Default User Avatar

    I got the same issue, just simplify your nested loops to bring down the complexity.

  • Custom User Avatar

    Besides solving the problem, the solution must be optimized enough to be able to handle the lists in the testcases (close to 10k in size each) Check the time complexity of your solution and think of ways to reduce it (e.g., from O(N^2) to O(N)).