Given a linked list and an integer k, reverse the first group of k nodes, leave the next group of k as-is, reverse the following group, and so on alternately (the first group is reversed). A final partial group follows the same alternating rule. Return the result as an array. Input: '[list], k'.
Input: '[list], k'.
Output: Array — the modified list.
Input: [1,2,3,4,5,6,7,8,9], 3
Output: [3,2,1,4,5,6,9,8,7]
Explanation: Reverse, keep, reverse.Input: [1,2,3,4,5], 2
Output: [2,1,3,4,5]
Explanation: Reverse first pair, keep next.Input: [1], 1
Output: [1]
Explanation: Single node reversed (itself).0<=n<=10^41<=k<=n