Hacking Leetcode runtimes!!

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 ch…


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.

Screenshot from leetcode solution

Screenshot about the atexit package


This content originally appeared on DEV Community and was authored by Tushar Tushar


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Hacking Leetcode runtimes!!." Tushar Tushar | Sciencx - Monday February 24, 2025, https://www.scien.cx/2025/02/24/hacking-leetcode-runtimes/
HARVARD
Tushar Tushar | Sciencx Monday February 24, 2025 » Hacking Leetcode runtimes!!., viewed ,<https://www.scien.cx/2025/02/24/hacking-leetcode-runtimes/>
VANCOUVER
Tushar Tushar | Sciencx - » Hacking Leetcode runtimes!!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/24/hacking-leetcode-runtimes/
CHICAGO
" » Hacking Leetcode runtimes!!." Tushar Tushar | Sciencx - Accessed . https://www.scien.cx/2025/02/24/hacking-leetcode-runtimes/
IEEE
" » Hacking Leetcode runtimes!!." Tushar Tushar | Sciencx [Online]. Available: https://www.scien.cx/2025/02/24/hacking-leetcode-runtimes/. [Accessed: ]
rf:citation
» Hacking Leetcode runtimes!! | Tushar Tushar | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.