dfs1 [LeetCode] 104. Maximum Depth of Binary Tree (javascript) 이진트리에서 가장 깊은 노드의 깊이를 구하는 문제이다. 깊이우선탐색으로 구할 수 있다. /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val===undefined ? 0 : val) * this.left = (left===undefined ? null : left) * this.right = (right===undefined ? null : right) * } */ /** * @param {TreeNode} root * @return {number} */ var maxDepth = function(root) { let depth = 0; const dfs = (root, len) =.. 2021. 5. 31. 이전 1 다음