Python3    ||   traverse the list and count   ||   T/S: 83% / 99%
\nclass Solution:\n    def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:\n        \n        sz, ptr = 0, head\n        \n        while ptr:\n     
```\nclass Solution:\n    def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:\n        \n        sz, ptr = 0, head\n        \n        while ptr:\n            ptr = ptr.next\n            sz+=1\n\n        if n==sz:\n            return head.next\n\n        sz -= n+1\n        ptr = head \n          \n        while sz > 0:\n            ptr = ptr.next\n            sz-=1\n            \n        ptr.next = ptr.next.next   \n        \n        return head\n\t\t\n```\t\n\n[https://leetcode.com/problems/remove-nth-node-from-end-of-list/submissions/596620800/](https://leetcode.com/problems/remove-nth-node-from-end-of-list/submissions/596620800/)\n\t\t
['Python']