Why are C and C++ so much slower than Java on leetcode?

My own tests usually show that C and C++ solutions are much faster than the Java versions.

However, leetcode frequently shows Java at or near 0 ms while C/C++ usually are higher.

What is going on?

I get the feeling that leetcode has a strange and nonstandard C/C++ compiler and runtime environment. On multiple occasions I've noticed anomalous compiler behavior that doesn't seem to match my versions of clang/clang++ and gcc/g++.

The timing measurements also seem broken and unpredictable; submitting the same code multiple times can yield wildly varying results.

Both the timing and memory judges seem very broken, which is very puzzling. What is the point of having time and memory judges if they produce unpredictable and wildly varying results?

Comments (1)