JAVA O(n) solution based on Maximum Depth of Binary Tree
public class Solution {\n    private boolean result = true;\n\n    public boolean isBalanced(TreeNode root) {\n        maxDepth(root);\n        return result;\n
    public class Solution {\n    private boolean result = true;\n\n    public boolean isBalanced(TreeNode root) {\n        maxDepth(root);\n        return result;\n    }\n\n    public int maxDepth(TreeNode root) {\n        if (root == null)\n            return 0;\n        int l = maxDepth(root.left);\n        int r = maxDepth(root.right);\n        if (Math.abs(l - r) > 1)\n            result = false;\n        return 1 + Math.max(l, r);\n    }\n    }
['Java']