✅ [Accepted] Solution for Swift
\nDisclaimer: By using any content from this post or thread, you release the author(s) from all liability and warranty of any kind. You are free to use the cont
<blockquote>\n<b>Disclaimer:</b> By using any content from this post or thread, you release the author(s) from all liability and warranty of any kind. You are free to use the content freely and as you see fit. Any suggestions for improvement are welcome and greatly appreciated! Happy coding!\n</blockquote>\n\n```swift\nclass Solution {\n    func removeNthFromEnd(_ head: ListNode?, _ n: Int) -> ListNode? {\n        let node = ListNode(0)\n        node.next = head\n        \n        var prev: ListNode? = node\n        var post: ListNode? = node\n        \n        for _ in 0..<n {\n            guard let next = post?.next else { continue }\n            post = next\n        }\n        \n        while let postNext = post?.next, let prevNext = prev?.next {\n            prev = prevNext\n            post = postNext\n        }\n        \n        prev!.next = prev!.next!.next\n        \n        return node.next\n    }\n}\n```\n\n<hr>\n\n<p>\n<details>\n<summary><b>ListNode + Extension</b></summary>\n\n```swift\npublic class ListNode {\n    public var val: Int\n    public var next: ListNode?\n    public init() { self.val = 0; self.next = nil; }\n    public init(_ val: Int) { self.val = val; self.next = nil; }\n    public init(_ val: Int, _ next: ListNode?) { self.val = val; self.next = next; }\n    \n    // An additional initializer that can be used to implement nodes from an array\n    public init?(_ array: [Int]) {\n        guard !array.isEmpty else { return nil }\n        self.val = array[0]\n        var prev: ListNode = self\n        for i in 1..<array.count {\n            let new = ListNode(array[i])\n            prev.next = new\n            prev = new\n        }\n    }\n}\n```\n\n```swift\nextension ListNode: Equatable {\n    public static func == (lhs: ListNode, rhs: ListNode) -> Bool {\n        return lhs.val == rhs.val && lhs.next == rhs.next\n    }\n}\n```\n\n</details>\n</p>\n\n<hr>\n\n<p>\n<details>\n<summary><img src="https://git.io/JDblm" height="24"> <b>TEST CASES</b></summary>\n\n<br>\n\n<pre>\nResult: Executed 3 tests, with 0 failures (0 unexpected) in 0.034 (0.036) 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.removeNthFromEnd(ListNode([1,2,3,4,5]), 2)\n        XCTAssertEqual(value, ListNode([1,2,3,5]))\n    }\n    func test1() {\n        let value = solution.removeNthFromEnd(ListNode([1]), 1)\n        XCTAssertEqual(value, ListNode([]))\n    }\n    func test2() {\n        let value = solution.removeNthFromEnd(ListNode([1,2]), 1)\n        XCTAssertEqual(value, ListNode([1]))\n    }\n}\n\nTests.defaultTestSuite.run()\n```\n\n</details>\n</p>
['Swift']