✅ [Java/C++] 100% Solution using Depth-First Search (Balanced Binary Tree)
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(log(n))\n Add your space complexity here, e.g. O(n) \n\
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(log(n))$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```Java []\nclass Solution {\n    boolean ans = true;\n    public int solve(TreeNode root)\n    {\n        if(root == null)\n            return 0;\n        int left = solve(root.left);\n        int right = solve(root.right);\n        if(Math.abs(left-right)>1)\n            ans = false;\n        return Math.max(left,right)+1;\n    }\n    public boolean isBalanced(TreeNode root) {\n        solve(root);\n        return ans;\n    }\n}\n```\n```C++ []\nclass Solution {\npublic:\n    bool ans = true;\n    int solve(TreeNode* root)\n    {\n        if(root == NULL)\n            return 0;\n        int left = solve(root->left);\n        int right = solve(root->right);\n        if(abs(left-right)>1)\n            ans = false;\n        return max(left,right)+1;\n    }\n    bool isBalanced(TreeNode* root) {\n        solve(root);\n        return ans;\n    }\n};\n```
['Tree', 'Depth-First Search', 'Binary Tree', 'C++', 'Java']