Is java faster than C++ ???


  • 0
    T

    When I compare java solutions with other C++ solutions in "Accepted page" I sometimes see that java solutions are faster than C++ ones in terms of running time. For example for this question : https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/. Is that an actual running time or am I missing something? I am kind of confused, as I have always been thinking that java is way slower than C++ due to two-step compilation process. Or there is another possibility that I can think of(Java test cases are very, very smaller than others???)


  • 1
    S

    More coder use Java. So Leetcode may run Java code on more powerful servers to support java users. C++ faster than Java in most time.


  • 0
    S

    One employer in LeetCode said that because java compile time is unstable, they have to remove compile and other procedure runtime from the benchmark.
    Which means for C/C++ solutions, compile time was counted in the runtime


  • 0
    V

    Why is this under Google?


  • 0
    A

    Please look at another topic which i raised about "can we trust these numbers at all". I compared C++ with C++.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.