Your question is Reverse Nodes in K Groups. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given the head of a singly linked list and an integer k, reverse the nodes of the list k at a time and return the modified head. If the number of remaining nodes is less than k, leave that final portion unchanged. The node values must stay attached to their original nodes; only links may be changed.
def reverse_k_group(head, k):