✔️ 100% Fastest Swift Solution
\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     public var val: Int\n *     public var next: ListNode?\n *     public init() { 
```\n/**\n * Definition for singly-linked list.\n * public 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 */\nclass Solution {\n    func removeNthFromEnd(_ head: ListNode?, _ n: Int) -> ListNode? {\n        var fast = head\n        var slow = head\n        var count = n\n\n        while count > 0 {\n            count -= 1\n            fast = fast?.next\n        }\n\n        if fast == nil { return head?.next }\n\n        while slow != nil && fast != nil {\n            if fast?.next == nil { slow?.next = slow?.next?.next } // end\n            slow = slow?.next\n            fast = fast?.next\n        }\n\n        return head\n    }\n\n}\n```\n\nLet me know in comments if you have any doubts. I will be happy to answer.\n\nPlease upvote if you found the solution useful.
['Swift']