Same solution but different run time on different submissions

Hi Leetcode community,

I tried to search for a similar post but couldn't find one so please either point me to a similar post or kindly provide your inputs here.

I solved a problem on Leetcode and submitted my solution and the results mentioned that the runtime was 24 ms and that my solution was faster than ~17% of cpp submissions.

Now, I tried submitting the solution again (same code no changes) within a few seconds of the above submission and I got a different results altogether. This time it mentioned that my solution took 12 ms ( half of before ) and was faster than ~81%

I find it bizzare! Anyone else experienced the same or know why this might happen ?

Screenshot attached for those of you who don't trust my eyes ( I didn't either, at first )

image

Thanks in advance!

Comments (3)