Skip to content

Practice Remove Nth Node From End of List

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#19
LeetCode Problem

Remove Nth Node From End of List

Problem Statement

Given the head of a linked list, remove the nth node from the end of the list and return its head. Follow up: Could you do this in one pass?

Source: Remove Nth Node From End of List on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

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

# Example 2

Input
head = [1], n = 1
Output
[]

# Example 3

Input
head = [1,2], n = 1
Output
[1]

Constraints

The number of nodes in the list is sz.
1 <= sz <= 30
0 <= Node.val <= 100
1 <= n <= sz

Related LeetCode Problems

Practice more problems similar to Remove Nth Node From End of List.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.