Same code with different results: AC and TLE


  • -1
    J

    I submit a solution six month ago for 3sum problem with a time complexity of O(n^2log(n)), and got an AC. But i got TLE when i resubmit the same code just today.
    Any changes to the OJ judging rules during this period?!

    thanks!


  • 0
    M

    TLE means your solution took too long. As the judge can't be expected to easily calculate time complexities for all the algorithms, it instead compares your solution against a set of times in milliseconds for how long it takes to finish. The time it compares against is set by the owners of the site as a time which the optimal solution should never exceed, but less efficient algorithms will.

    Since your algorithm passed before, and not now, you likely have a non-optimal solution, which was lucky enough to come in under the time limit the first time.

    PS: Thanks to loick and gautamnitc, we know the optimal solution in O(n^2), not O(n^2 logn).


  • 0
    J

    thanks for your reply!
    I know how OJ works and i understand what you mean.
    I'm just very curious about whether the administrator has reset the time limit during this six month period.


  • 0
    M

    Considering the difference in time complexities between your answer and the optimal, it is unlikely that the time limit has changed.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.