package
0.0.0-20241221191246-b80a13d7bbe0
Repository: https://github.com/yvv4git/go-algorithms.git
Documentation: pkg.go.dev

# README

61. Rotate List

Level - medium

Task

Given the head of a linked list, rotate the list to the right by k places.

Example 1:

img.png

Input: head = [1,2,3,4,5], k = 2
Output: [4,5,1,2,3]

Example 2:

img_1.png

Input: head = [0,1,2], k = 4
Output: [2,0,1]

Constraints:

  • The number of nodes in the list is in the range [0, 500].
  • -100 <= Node.val <= 100
  • 0 <= k <= 2 * 109