New update is available. Click here to update.

Last Updated: 2 Dec, 2020

Difficulty: Moderate

```
Given Linked List : 1 2 3 4 -1 and K : 2
Then the modified Linked List after K rotation : 3 4 1 2
```

```
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case contains single space-separated integers, denoting the elements of the Linked List with -1 being the last element denoting the end of the List (or null element).
The next line of each test case contains an integer ‘K’, representing the number of positions up to the given Linked List that has to rotate.
```

```
For each test case, print the elements of the resultant Linked List after rotating by ‘K’ positions in a clockwise direction.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^5
0 <= node.data <= 10^9 and node.data != -1
0 <= ‘K’ <= 10^5
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Deletion In Doubly Linked List

Posted: 22 Apr, 2022

Difficulty: Easy

Insertion In Doubly Linked List

Posted: 24 Apr, 2022

Difficulty: Easy

LRU Cache

Posted: 10 Sep, 2022

Difficulty: Moderate

Delete Nodes On Regular Intervals

Posted: 19 Dec, 2022

Difficulty: Ninja

Add One To Linked List

Posted: 19 Dec, 2022

Difficulty: Hard

Popular Interview Problems: