Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ236
Page ↗
Q236FWASIC interview problem

Remove the nth node from the end

TechniquesLinked listTwo pointers
DifficultyMedium
TopicLinked Lists
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

Remove the nth node from the end of a singly linked list in one traversal and return the head.

Example input and output

Use this case to check your interpretation
Input
head = 1 -> 2 -> 3 -> 4 -> 5, n = 2
Output
1 -> 2 -> 3 -> 5
Explanation

Keeping the lead pointer two nodes ahead places the trailing pointer immediately before node 4.

02

Requirements (3)

  • Treat n as one-based from the tail.
  • Leave the list unchanged when n is not positive or exceeds the list length.
  • Correctly remove the head when n equals the list length.