prevTail
to keep track of the tail of the previous reversed group, currentHead
to mark the start of the current group, and nextHead
to mark the start of the next group.k
nodes, reverse the group. Keep track of the new head and tail of the reversed group.prevTail
to the new head of the reversed group.prevTail
to the new tail of the reversed group.k
nodes by setting currentHead
to nextHead
.k
nodes, do not reverse it.