Code Room
CodingHard
Question
Given a singly linked list encoded as a Python list of integers and an integer k, reverse the nodes of the list k at a time and return the resulting sequence as a Python list. Nodes in a final group with fewer than k elements are left as-is (not reversed). k is between 1 and the length of the list; the list has up to 5000 nodes.
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.
Learn the concepts
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.