标签:mat find ini abs neu public pre nod color
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { int result = 0; public int findTilt(TreeNode root) { subSum(root); return result; } private int subSum(TreeNode root){ if(root == null){ return 0; } int left = subSum(root.left); int right = subSum(root.right); result += Math.abs(left - right); return left + right + root.val; } }
标签:mat find ini abs neu public pre nod color
原文地址:https://www.cnblogs.com/tobeabetterpig/p/9335081.html