Rotate List

Authentic source (rev3): LeetCode 61 "Rotate List". Given the head of a linked list, rotate the list to the right by k places and return the new head.

Rotate right by k means the last k nodes move to the front while relative order is preserved. Use k mod n where n is the list length. Perform original-node relinking (rewire next pointers); do not solve by returning identity-by-values or by a default k=0 simplification.

Examples
Input: [[1,2,3,4,5],2]
Output: [4,5,1,2,3]
Hints

Rotate List

Authentic source (rev3): LeetCode 61 "Rotate List". Given the `head` of a linked list, rotate the list to the right by `k` places and return the new head.