less than 1 minute read

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 where n is the number of nodes in node

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 =

Solution

Leave a comment