Back to problems

Reverse the Order of k-Groups in a Linked List

Algorithm · ByteDance · Medium

You are given the first node of a singly linked list and an integer k. Read the nodes from left to right and partition them into consecutive blocks containing at most k nodes. The nodes inside each complete block must stay in their original order. However, the complete blocks themselves must appear in reverse order. If the final block has fewer than k nodes, leave that incomplete block after all reordered complete blocks without changing its internal order. Input Format n…

Checking your access…