head of a singly linked list and an integer k. Do the following k times: detach the last node and put it at the front of the list.
Return the head of the resulting list. k can be far larger than the list's length, so literally repeating the step k times will not do.head=list_node([10, 20, 30, 40]), k=1 → [40, 10, 20, 30]
The last node 40 moves to the front: [40, 10, 20, 30].
head=list_node([5, 6]), k=3 → [6, 5]
Two steps bring the list back to where it was, so three steps are the same as one: [6, 5].
head=list_node([]), k=7 → None
An empty list stays empty.
Node.val ≤ 100head=list_node([10, 20, 30, 40]), k=1
[40, 10, 20, 30]
Run checks the first 3 tests in your browser. Submit checks all 102 tests on the server, hidden ones included.