public boolean isBalanced(TreeNode root) {
            if (root == null)
                return true;
            if (isBalanced(root.left) && isBalanced(root.right)) {
                int leftHeight = getHeight(root.left);
                int rightHeight = getHeight(root.right);
                if (Math.abs(leftHeight - rightHeight) <= 1)
                    return true;
            }
            return false;
        }