💡JavaScript Solution
The idea - DFS O(N) \n1. Postorder DFS to find the height of every node\n2. If any subtree is not balanced, encrypt the information as Infinity\n\nvar isBalance
### The idea - DFS O(N) \n1. Postorder DFS to find the height of every node\n2. If any subtree is not balanced, encrypt the information as `Infinity`\n```\nvar isBalanced = function(root) {\n    \n    let dfs = function(node) {\n        if (!node) return 0;\n        let left = 1 + dfs(node.left);\n        let right = 1 + dfs(node.right);\n        if (Math.abs(left - right) > 1) return Infinity;\n        return Math.max(left, right);\n    }\n    \n    return dfs(root)==Infinity?false:true;\n};\n```\n\n### The idea - DFS O(N^2)\n1. Standard Top-Down recursion\n``` javascript\nvar isBalanced = function(root) {\n    if (!root) return true;\n    \n    let height = function(node) {\n        if (!node) return 0;\n        return 1 + Math.max(height(node.left), height(node.right));\n    }\n    \n    return Math.abs(height(root.left) - height(root.right)) < 2 && isBalanced(root.left) && isBalanced(root.right);\n}\n```
['JavaScript']