Code Room
CodingHardcod-g781
Subject Linked listsLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A singly linked list is given as a plain list of values in head-to-tail order. Reverse the nodes k at a time and return the resulting list of values. Nodes that don't form a complete group of k at the end are left in their original order. 1 <= k. The list may be empty.

Implement
reverse_k_group(values: list[int], k: int) → list[int]
Examples
in[[1,2,3,4,5],2]out[2,1,4,3,5]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.