Easiest Solution of all O(n)


#1
int res = 1;
int F(TreeNode *A)
{
    if(A == NULL) return 0;
    
    int lh = F(A->left);
    int rh = F(A->right);
    
    if(abs(lh - rh) > 1) res = 0; 
    return max(lh, rh) + 1;
}
int Solution::isBalanced(TreeNode* A) 
{
    res = 1;
    F(A);
    
    return res;
}