Java || Recursive Easy Solution with Explanation || 0ms
\nclass Solution \n{\n    boolean flag= true;//setting the balanced flag default by true \n    public boolean isBalanced(TreeNode root) \n    {\n        if(root
```\nclass Solution \n{\n    boolean flag= true;//setting the balanced flag default by true \n    public boolean isBalanced(TreeNode root) \n    {\n        if(root == null)//base case for null graph \n           return true;\n        height_bal(root);//calculates the height and the balance factor simultaneously for each subtree \n        return flag;//returning the flag \n    }\n    public int height_bal(TreeNode root)//Height is calculated on the basis of node\n    {//DFS(postorder)\n        if(root == null)\n            return 0;\n        \n        int left= height_bal(root.left);//recursively traveling the left subtree\n        int right= height_bal(root.right);//recursively traveling the right subtree\n        \n        int max= Math.max(left, right)+1;//getting the maximum height among left and right subtree and adding 1 for each level of BT\n    \n        if(Math.abs(left-right) >1)//balanceing the left and right subtree condition \n            flag= false;//not balanced flag\n        \n        return max;//returning the maximum height for the particular subtree\n    }\n}//Do Upvote, it helps a lot \n```
['Depth-First Search', 'Recursion', 'Binary Tree', 'Java']