The key idea is to keep track of the `next_head`

while reversing the group, `tail`

of the current group is always the start node of the group, once the group reversing is done, `next_head`

is available, simply connect it to `tail`

.

```
def reverseKGroup(self, head, k):
if head is None or k < 2:
return head
next_head = head
for i in range(k - 1):
next_head = next_head.next
if next_head is None:
return head
ret = next_head
current = head
while next_head:
tail = current
prev = None
for i in range(k):
if next_head:
next_head = next_head.next
_next = current.next
current.next = prev
prev = current
current = _next
tail.next = next_head or current
return ret
```