← All questions
Coding
Reverse Nodes in k-Group
Asked at
Agoda
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
- 01Use a dummy head and group predecessor
- 02Find the kth node before reversing
- 03Leave an incomplete group intact
- 04Reverse nodes within the group boundary
- 05Reconnect predecessor, tail, and next group
Reference answer
Then expect these follow-ups
How would you write the recursive form?
Tests: follow-up reasoning
Why does prev begin at groupNext?
Tests: correctness reasoning
Free to read · better with Enzo
Practice this out loud with Enzo
Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.
Next question