Coding Challenge

Remove Nth Node From End of List

Medium
linked-listtwo-pointers

Remove the nth node from the end in one pass.

Given a linked list head, remove the nth node from the end of the list and return the new head.

Examples

Input: head = [1,2,3,4,5], n = 2

Output: [1,2,3,5]

Constraints

  • 1 <= n <= list size

Preparing your coding workspace...