Share my 3 lines python code

  • 2
    class Solution:
    def maxDepth(self, root):
        if not root:
            return 0
        return max(self.maxDepth(root.left) + 1, self.maxDepth(root.right) + 1)

  • 0

    yeah, I got the same code. But the running time is 93ms. I'm quite curious about how can it be shortened to 50ms.

Log in to reply

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