✅ [Solution] Swift: Balanced Binary Tree
swift\nclass Solution {\n    func isBalanced(_ root: TreeNode?) -> Bool {\n        guard let root = root else { return true }\n        if !isBalanced(root.left)
```swift\nclass Solution {\n    func isBalanced(_ root: TreeNode?) -> Bool {\n        guard let root = root else { return true }\n        if !isBalanced(root.left) || !isBalanced(root.right) { return false }\n        return abs(val(root.left) - val(root.right)) <= 1\n    }\n    private func val(_ tn: TreeNode?) -> Int {\n        guard let node = tn else { return -1 }\n        return 1 + max(val(node.left), val(node.right))\n    }\n}\n```\n\n<hr>\n\n<details>\n<summary><img src="https://git.io/JDblm" height="24"> <b>TEST CASES</b></summary>\n\n<pre>\nResult: Executed 3 tests, with 0 failures (0 unexpected) in 0.032 (0.034) seconds\n</pre>\n\n```swift\nimport XCTest\n\nclass Tests: XCTestCase {\n    \n    private let solution = Solution()\n    \n    func test0() {\n        let value = solution.isBalanced(TreeNode([3,9,20,nil,nil,15,7]))\n        XCTAssertEqual(value, true)\n    }\n    \n    func test1() {\n        let value = solution.isBalanced(TreeNode([1,2,2,3,3,nil,nil,4,4]))\n        XCTAssertEqual(value, false)\n    }\n    \n    func test2() {\n        let value = solution.isBalanced(TreeNode([]))\n        XCTAssertEqual(value, true)\n    }\n}\n\nTests.defaultTestSuite.run()\n```\n\n</details>
['Swift']