Given a linked list A of length N and an integer B.
You need to reverse every alternate B nodes in the linked list A.
Problem Constraints
1 <= N <= 10
5
1<= Value in Each Link List Node <= 10
3
1 <= B <= N
N is divisible by B
Input Format
First argument is the head pointer of the linkedlist A.
Second argument is an integer B.
Output Format
Return the head pointer of the final linkedlist as described.
Example Input
Input 1:
A = 3 -> 4 -> 7 -> 5 -> 6 -> 6 -> 15 -> 61 -> 16
B = 3
Input 2:
A = 1 -> 4 -> 6 -> 6 -> 4 -> 10
B = 2
Example Output
Output 1: