Remove Nth Node From End of List
Easy
Given the head of a linked list, remove the nth node from the end of the list and return its head.
Example 1
Input
5 1 2 3 4 5 2
Output
1 2 3 5
Explanation
The 2nd node from the end is 4, so it is removed.
Constraints
1 <= number of nodes <= 30
0 <= Node.val <= 100
1 <= n <= number of nodes
Hints:
Hint 1
Use two pointers, fast and slow.
Hint 2
Move the fast pointer n nodes ahead of the slow pointer.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 10, 2026
Last updated
Aug 11, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Report a correction:editorial@examadda.org
Auto
Loading editor...
Input
Expected Output