LeetCode力扣 104. 二叉樹的最大深度 Maximum Depth of Binary Tree 題解代碼 JavaScript

問題 https://leetcode-cn.com/problems/maximum-depth-of-binary-tree/submissions/

練習使用JavaScript解答

/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var maxDepth = function(root) {
    if(!root)
        return 0;
    return Math.max(arguments.callee(root.left), arguments.callee(root.right)) + 1;
};

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章