Given the head of a Linked-List and a number k, reverse every alternating ‘k’ sized group from the head.
If, in the end, you are left with a group with less than ‘k’ elements, reverse it too.
E.g.
- Inputs:
k = 2, 1->2->3->4->5->6->7->8->null
- Output:
2->1->3->4->6->5->7->8->null