#416 Remove Node from End of List
A pointer head to the beginning of a linked list is given. Remove the nth node from the end of the list and return the head of the modified list.
Examples:
Input: head = [1,2,3,4,5], n = 2
Output: [1,2,3,5]
Input: head = [1], n = 1
Output: []
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
Question review
Sign in to start the dialogue
The mentor keeps the context of the current question and your previous messages.
Sign in
Available with Premium
This is just one of the solutions available with Premium. And more:
- 250+ advanced lectures
- 1300+ practice exercises
- 500+ solutions to problems from real interviews
- Personalized Java Hub certificates
- Expanded access to the AI mentor