Rotate Linked List by K
Given a linked list node
and a non-negative integer k
, rotate the list to the right by k
places.
Note: The linked list is guaranteed to have at least one element, and k is guaranteed to be less than or equal to the length of the list.
Constraints
k ≤ n ≤ 100,000
wheren
is the number of nodes innode
https://binarysearch.com/problems/Rotate-Linked-List-by-K
Examples
Example 1
Input
- node =
- k =
4
Output
- answer =
Example 2
Input
- node =
- k =
0
Output
- answer =
Example 3
Input
- node =
- k =
2
Output
- answer =
Leave a comment