Reverse Nodes in k-Group

Asked atAgoda
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+
  1. 01Use a dummy head and group predecessor
  2. 02Find the kth node before reversing
  3. 03Leave an incomplete group intact
  4. 04Reverse nodes within the group boundary
  5. 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

Hiring now

Agoda has 245 open roles right now

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Customer Experience Specialist - Graveyard Shift (Kuala Lumpur)

    Kuala Lumpur, Malaysia

  • Payment disputes coordinator (10-month contract) (Bangkok-Based, No Visa Provided)

    Bangkok, Thailand

  • Payment Operations Coordinator (10-month contract) (Bangkok-Based, No Visa Provided)

    Bangkok, Thailand

Or practice this question first

Next question