[LeetCode]Remove Nth Node From End of List
public class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { ListNode dummy = new ListNode(0); dummy.next = head; head = dummy; ListNode pre = head; ListNode p = pre.next; for (int i = 0; i < n; i++) { p = p.next; } while (p != null) { p = p.next; pre = pre.next; } pre.next = pre.next.next; return head.next; } }