Golang solution (3ms)
Example Input:\n\n| 1 | -> | 2 | -> | 3 | -> | 4 | -> | 5 |\n\nFig 1\n\n#### First Approach \n- The idea is to use two pointers left and right.\n- right will ad
Example Input:\n```\n| 1 | -> | 2 | -> | 3 | -> | 4 | -> | 5 |\n\nFig 1\n```\n#### First Approach \n- The idea is to use two pointers `left` and `right`.\n- `right` will advance `n` nodes into the list.\n- At this point `left` will point to the head of the list. (Figure 2)\n- Then, we walk `left` and `right` in tandem, until `right` reaches the end of the list.\n- At this point `left` will point to the *Nth node from the end*, which we want to remove.  (Figure 3)\n```\nleft                       right\n| 1 | -> | 2 | -> | 3 | -> | 4 | -> | 5 |\n\nFig 2\n```\n```\n                  left                    right\n| 1 | -> | 2 | -> | 3 | -> | 4 | -> | 5 |   *\n\nFig 3\n```\nThis will work. However, we have to maintain a previous pointer to `left`, in order to delete `left`. We also need to take care of the corner case where, the node to be deleted is the `head` of our list. i.e when `n` = 5 in our example.\n\nWe'll instead follow a cleaner approach which is discussed next.\n#### Second Approach\n- We employ a node called the `preHeader` node, whose `Next` pointer points to the head of our list.\n- Then we point our `left` pointer to the `preHeader` to start off with. (Figure 4)\n- The advantage of this approach is that, when our `right` pointer gets to the end of our list, `left` will be pointing to the node just before the *Nth node from the end*, which makes deleting that node very straight forward.  (Figure 5/6)\n- Another advantage is that, we do not need to code anything special for handling the corner case where `n` = 5 in our example. \n```\nleft                                 right\n| ph | -> | 1 | -> | 2 | -> | 3 | -> | 4 | -> | 5 |\n\nFig 4\n```\n```\n                   left                             right\n| ph | -> | 1 | -> | 2 | -> | 3 | -> | 4 | -> | 5 |   *\n\nFig 5\n```\n```\n                   left                    right\n| ph | -> | 1 | -> | 2 | -> | 4 | -> | 5 |   *\n\nFig 6\n```\n\n```c\nfunc removeNthFromEnd(head *ListNode, n int) *ListNode {\n    if head == nil || n <= 0 {return head}\n    preHeader := &ListNode{Next: head}\n    left, right := preHeader, head\n\n    for i := 0; right != nil && i < n; i++ {\n        right = right.Next\n    }\n    for right != nil {\n        left, right = left.Next, right.Next\n    }\n    left.Next = left.Next.Next\n    return preHeader.Next\n}\n```
[]