Remove Nth Node From End
Problem Statement
Given the head of a singly linked list and an integer
nnRules and Constraints
- The linked list is 1-indexed.
- The size of the list is , and
Nis guaranteed to be within the valid rangen.[1, N] - The list does not contain duplicates and nodes do not have a value that is the same as .
n - It is not allowed to access the list in a reverse direction.
- The time complexity of the solution should be O(L), where is the length of the list.
L - The space complexity of the solution should be O(1).
Note that the problem is asking to remove the node at the
nExample
Input: {"head":[1,2,3,4,5],"n":2} Output: [1,2,3,5]
CompaniesMicrosoft
JavaScript
Login to write code
Solve problems, verify your skills, and earn XP.