Reverse every k nodes of a given linked list, where k is a positive integer.
Given the head of a linked list and an integer k, reverse every k nodes of the linked list in-place. The nodes from index i to i+k-1 should form a reversed group.
The original list should still be accessible and usable during the process, with all elements correctly linked after reversing every k nodes. This modification does not change the overall length of the list.
Note: This problem can be solved in-place, without modifying the original list or creating a new linked list.
Input: {"head":[1,2,3,4,5],"k":2} Output: [2,1,4,3,5]
Solve problems, verify your skills, and earn XP.