Remove Nth Node From End of List
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given the head of a singly linked list and an integer n, remove the node that is n-th from the end (the last node is 1st from the end) and return the head of the modified list.
n is always valid, that is 1 <= n <= length. When n equals the length, the head itself is removed. If the list becomes empty, return null.
Try to do it in one pass over the list.
Examples
Constraints
- 1 <= number of nodes (sz) <= 10^4
- 0 <= Node.val <= 100
- 1 <= n <= sz
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.