> For the complete documentation index, see [llms.txt](https://zedive.gitbook.io/project-l/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zedive.gitbook.io/project-l/part-1/basic_data_structure/linked_list/singly-linked-list/rotate-list.md).

# Rotate List

## Question ([LC.61](https://leetcode.com/problems/rotate-list/?tab=Description))

> Given a list, rotate the list to the right by k places, where k is non-negative.

## Example

```
Input: 1->2->3->4->5->null, 2
Output: 4->5->1->2->3->null

Input: 1->2->3->4->5->null, 6
Output: 5->1->2->3->4->null !!!
```

## Analysis

How do we get to the ith node in singly linked list? Get the total length. Then for loop until `(len - k % len)`.

## Code

later
