A Balanced Binary Tree is a binary tree where the height difference between the left and right subtrees of every node is at most 1.

This ensures the tree is not too skewed, which keeps operations like search, insert, and delete efficient (O(log n) in height-balanced trees).

https://leetcode.com/problems/balanced-binary-tree/description/

https://takeuforward.org/data-structure/check-if-the-binary-tree-is-balanced-binary-tree/

class Solution {
public:

    int helper(TreeNode* root){
        if(!root) return 0;

        int leftheight = helper(root->left); 
        if(leftheight == -1) return -1;
        int rightheight = helper(root->right);
        if(rightheight == -1) return -1;
        if(abs(leftheight - rightheight) > 1) return -1;
        return max(leftheight , rightheight) +1;
    }

    bool isBalanced(TreeNode* root) {
        if(!root) return true;

        return (helper(root) != -1);
    }
};