100% FASTER🏎️🔥|| RECURSIVE DFS SOLUTION😁
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->O(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->O(1)\n![Screenshot_20230205_171246.png](https://assets.leetcode.com/users/images/c8ce517f-5018-4b34-aa5a-bfc27b3dc48c_1680025816.5160778.png)\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode() {}\n *     TreeNode(int val) { this.val = val; }\n *     TreeNode(int val, TreeNode left, TreeNode right) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\nclass Solution {\n\n    public boolean isBalanced(TreeNode root) {\n        // Call the dfsHeight function to get the height of the tree\n        // If the returned value is -1, the tree is not balanced\n        // Otherwise, it is balanced\n        return dfsHeight(root) != -1;\n    }\n\n    public static int dfsHeight(TreeNode root){\n\n        // Base case: If the root is null, the height is 0\n        if(root == null){\n            return 0;\n        }\n    \n        // Recursively get the height of the left subtree\n        int leftHeight = dfsHeight(root.left);\n\n        // If the left subtree is not balanced, return -1\n        if(leftHeight == -1){\n            return -1;\n        }\n    \n        // Recursively get the height of the right subtree\n        int rightHeight = dfsHeight(root.right);\n        \n        // If the right subtree is not balanced, return -1\n        if(rightHeight == -1){\n            return -1;\n        }\n    \n        // If the absolute difference between the left and right subtree heights\n        // is greater than 1, the tree is not balanced, so return -1\n        if(Math.abs(leftHeight - rightHeight) > 1){\n            return -1;\n        }\n    \n        // Otherwise, return the maximum height of the left and right subtrees, plus 1\n        // This represents the height of the current node\n    return Math.max(leftHeight,rightHeight)+1;\n    }\n}\n```
['Tree', 'Depth-First Search', 'Binary Tree', 'Java']