I Submit 4 times with same code, but runtime is not same,like this:
is the tests not same eveytime ？
The runtime will not always be the same, it varies greatly on the available system resources and/or network latency (e.g leetcode is calling another backend service from its judger), especially when the runtime is measured at 1ms level. An example: even when you boot your laptop, it may not always be ready within the same amount of time, right? ;)
For Java and C#, my numbers are all over the place - the same code can be faster than 75% of all submissions or only faster than 25% of all submissions depending on the weather.
They should test on virtual hardware so they can actually count the number of CPU instructions, memory allocations, etc and then calculate a deterministic representative value based on observed norms. That would give a truer picture of the efficiency.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.