DescriptionQ848
Q848FWASIC interview problem
Reverse a singly linked list
TechniquesLinked listPointers
DifficultyEasy
TopicLinked Lists
LanguageSystemVerilog
Requirements3 checkpoints
01
Problem
Reverse a singly linked list in place and return its new head.
Example input and output
Use this case to check your interpretationInput
head = 1 -> 2 -> 3 -> nullOutput
3 -> 2 -> 1 -> nullExplanation
Each next pointer is reversed once, and the original tail becomes the new head.
02
Requirements (3)
- Do not allocate replacement nodes.
- Preserve the next node before changing the current link.
- Return null for an empty input list.
