Reverse in Groups of K

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • hard
  • Pro

Given a linked list and a number k, reverse the nodes in each consecutive group of k, and leave any final group shorter than k as it is. Explain how you reconnect the groups.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →