class Solution {
public:
    bool result = true;
    int dfs(TreeNode* pRoot){
        if(pRoot == NULL)
            return 0;
        int left = dfs(pRoot->left);
        int right = dfs(pRoot->right);
        if(result && abs(left - right) >= 2)
            result = false;
        return max(left,right) + 1;
    }
    bool IsBalanced_Solution(TreeNode* pRoot) {
        if(pRoot == NULL)
            return true;
        dfs(pRoot);
        return result;
    }
};