AI Features

Rotate a Linked List

Given the head of a singly linked list and an integer 'n' rotate the linked list by 'n'.

Statement

Given the head of a singly linked list and an integer n, rotate the linked list by n and return the rotated linked list.

Example

Below is an example of sample input and expected output linked list after rotating by 22.

Note: The value of n can be larger than the length of the linked list. ...

Sample input

Ask