Take the interleaving string question as an example, Java solutions seems to be the slowest among those 3 languages. Is Java generally considered to be faster than python? I have seen quite a few such cases, which makes me wonder if Leetcode is using a faster machine to run python than Java.
I think it's because python is implemented by C, which makes sense it's faster than Java...
But isn't Java implemented by a lower level language that could be even faster than C?
- The time of Java solution may added JVM time. Start JVM from scratch is slower than start Python VM.
- The code length of Java solutions is short, could not invoke JIT.
- Leet code doesn't count the time of compile C++ code.
It seems to me that Java library algorithms are implemented mostly in Java. See the stackoverflow link:
The really low-level stuff like networking is implemented in C or lower-level languages.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.