✅ [Solution] Swift: Arithmetic Subarrays
swift\nclass Solution {\n    func checkArithmeticSubarrays(_ nums: [Int], _ l: [Int], _ r: [Int]) -> [Bool] {\n        var result: [Bool] = []\n        for i in
```swift\nclass Solution {\n    func checkArithmeticSubarrays(_ nums: [Int], _ l: [Int], _ r: [Int]) -> [Bool] {\n        var result: [Bool] = []\n        for i in 0..<l.count {\n            let arr = [Int](nums[l[i]...r[i]]).sorted()\n            var found = true\n            for i in 2..<arr.count where arr[i] - arr[i-1] != (arr[1] - arr[0]) {\n                found = false\n                break\n            }\n            result.append(found)\n        }\n        return result\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.012 (0.014) seconds\n</pre>\n\n```swift\nimport XCTest\n\nclass Tests: XCTestCase {\n\n    private let solution = Solution()\n    \n    /*\n     In the 0th query, the subarray is [4,6,5]. This can be rearranged as [6,5,4], which is an arithmetic sequence.\n     In the 1st query, the subarray is [4,6,5,9]. This cannot be rearranged as an arithmetic sequence.\n     In the 2nd query, the subarray is [5,9,3,7]. This can be rearranged as [3,5,7,9], which is an arithmetic sequence.\n    */\n    func test0() {\n        let value = solution.checkArithmeticSubarrays([4,6,5,9,3,7],[0,0,2],[2,3,5])\n        XCTAssertEqual(value, [true,false,true])\n    }\n    \n    func test1() {\n        let value = solution.checkArithmeticSubarrays([-12,-9,-3,-12,-6,15,20,-25,-20,-15,-10],\n                                                      [0,1,6,4,8,7],\n                                                      [4,4,9,7,9,10])\n        XCTAssertEqual(value, [false,true,false,false,true,true])\n    }\n}\n\nTests.defaultTestSuite.run()\n```\n\n</details>
['Swift']