Remove Nth Node From End of List
Given the head of a linked list, remove the nth node from the end of the list and return its head.

30:00

Remove Nth Node From End of List
medium
Topics
Companies

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

Example 1:
Input: {"head":[1,2,3,4,5],"n":2}
Output: [1,2,3,5]
Constraints:
  • The number of nodes is szsz.

  • 1sz301 \leq sz \leq 30

  • 0Node.val1000 \leq \text{Node.val} \leq 100

  • 1nsz1 \leq n \leq sz

Input
arr ={"head":[1,2,3,4,5],"n":2}

Init dummy, left=dummy, right=head

left

0

right

1

2

3

4

5

NULL
Variables
No variables to display
DepthFunction Call
Stack empty
0/12