This content originally appeared on DEV Community and was authored by Tushar Tushar
In my opinion it is way bigger achievement than actually solving that particular problem in the lowest time whoever did this, you my friend.. you have earned my respect!!
While working through a recent LeetCode problem after solving it I went on to check out the best solutions and other ways to solve the problem and I came across one really bright mind.
One of the solutions had a piece of code that reverse-engineered how LeetCode displays runtime results. Yep, someone actually figured out a way to modify the runtime display to always show 0 ms, regardless of the actual performance of the algorithm.
This code essentially manipulates the system and writes "0" into a file when the program exits, effectively "hiding" the real performance.
it uses a module called atexit
i.e. "at exit" which then receives a function to register and unregistered cleanup functions, and then it takes a lambda function which opens the "display_runtime.txt" and writes 0 to it.
This content originally appeared on DEV Community and was authored by Tushar Tushar

Tushar Tushar | Sciencx (2025-02-24T20:19:25+00:00) Hacking Leetcode runtimes!!. Retrieved from https://www.scien.cx/2025/02/24/hacking-leetcode-runtimes/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.