public class TreeSum { public int findSum(TreeNode root) { if (root == null) return 0; int sum = 0; sum = findSum(root.left) + findSum(root.right) + root.val; return sum; } }
No comments:
Post a Comment