Javascript Solution


  • 0
    T
    var maxDepth = function(root) {
        if(root == null){
            return 0
        }
        var nodeLeft = maxDepth(root.left) + 1
        var nodeRight = maxDepth(root.right) + 1
        var result = nodeLeft > nodeRight ? nodeLeft : nodeRight
        return result
    }
    

Log in to reply
 

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