JAVA_Merge Two Binary Trees_LeetCode 617


JAVA_Merge Two Binary Trees_LeetCode 617

JAVA_Merge Two Binary Trees_LeetCode 617 풀이 class Solution { public TreeNode mergeTrees(TreeNode root1, TreeNode root2) { if (root1 == null && root2 == null) return null; else if (root1 == null) return root2; else if (root2 == null) return root1; return new TreeNode(root1.val + root2.val, mergeTrees(root1.left, root2.left), mergeTrees(root1.right, root2.right)); } } * 출처 Merge Two Binary Trees - LeetCode Merge Two Binary Trees - You are given two binary trees root1 and root2. Imagine that when y...


#JAVA #JAVA_LeetCode617 #JAVA_MergeTwoBinaryTrees #JAVA_MergeTwoBinaryTrees_LeetCode617 #MergeTwoBinaryTrees_LeetCode617

원문링크 : JAVA_Merge Two Binary Trees_LeetCode 617