题目
1 class Solution { 2 public: 3 int ans = 0; 4 int findTilt(TreeNode* root) { 5 postOrder(root); 6 return ans; 7 } 8 int postOrder(TreeNode* root){ 9 if(root == NULL) return 0; 10 int leftSum = postOrder(root->left); 11 int rightSum = postOrder(root->right); 12 ans += abs(leftSum - rightSum); 13 return root->val + leftSum + rightSum; 14 } 15 };