✅ [Solution] Swift: Longest Consecutive Sequence
swift\nclass Solution {\n    func longestConsecutive(_ nums: [Int]) -> Int {\n        guard nums.count > 1 else { return nums.count }\n        let setSort = Set
```swift\nclass Solution {\n    func longestConsecutive(_ nums: [Int]) -> Int {\n        guard nums.count > 1 else { return nums.count }\n        let setSort = Set(nums).sorted()\n        var longest = 0, count = 1, num = 0\n        \n        while num < setSort.count {\n            if num - 1 >= 0, setSort[num - 1] == setSort[num] - 1 {\n                count += 1\n            } else {\n                longest = max(count, longest)\n                count = 1\n            }\n            num += 1\n        }\n        return max(count, longest)\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 2 tests, with 0 failures (0 unexpected) in 0.008 (0.010) seconds\n</pre>\n\n```swift\nimport XCTest\n\nclass Tests: XCTestCase {\n    \n    private let solution = Solution()\n    \n    // The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.\n    func test0() {\n        let value = solution.longestConsecutive([100,4,200,1,3,2])\n        XCTAssertEqual(value, 4)\n    }\n    \n    func test1() {\n        let value = solution.longestConsecutive([0,3,7,2,5,8,4,6,0,1])\n        XCTAssertEqual(value, 9)\n    }\n}\n\nTests.defaultTestSuite.run()\n```\n\n</details>
['Swift']