Queue and recursion, which one is more efficient?

  • 0

    I implemented maximum depth both using queue and recursion. Although I think the time complexity are both O(n), but isn't recursion more expensive and time-consuming? From the running time of results, it turned out using queue cost more time, what cause this? because there aren't many test cases?

  • 0

    SUBMIT AGAIN !!! The time-consuming is related to the judge system status.

Log in to reply

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