JAVA_Diameter of Binary Tree_LeetCode 543


JAVA_Diameter of Binary Tree_LeetCode 543

JAVA_Diameter of Binary Tree_LeetCode 543 풀이 class Solution { private int len = 0; public int diameterOfBinaryTree(TreeNode root) { diameter(root); return len; } private int diameter(TreeNode root){ if (root == null) return 0; int left_height = diameter(root.left); int right_height = diameter(root.right); len = Math.max(len , left_height+right_height); return Math.max(left_height , right_height) + 1; } } * 출처 Diameter of Binary Tree - LeetCode Diameter of Binary Tree - Given the root of a binary...


#DiameterofBinaryTree_LeetCode543 #JAVA #JAVA_DiameterofBinaryTree #JAVA_DiameterofBinaryTree_LeetCode543 #JAVA_LeetCode543

원문링크 : JAVA_Diameter of Binary Tree_LeetCode 543