Killjee And Linked List

5

2 votes
Easy
Problem

THIS IS A FUNCTION PROBLEM. YOU NEED TO COMPLETE THE SOLVE FUNCTION ONLY. PLEASE DON'T CHANGE CODE OF main() FUNCTION. THIS IS FOR YOUR OWN GOOD.

In this problem you have to complete a function. There are three parameters of the solve function. 

  1. Root -> it is starting node of a singly linked list structure node has two variables val and next. val is of type integer and next is pointer of type node.

You are also given two integers L and R you need to rotate the sublink list from L to R in anticlock wise manner by 1 element. 

For Example:

    Given Linked list is 2->3->4->5->6->7 and L=2 and R=5

    rotating the sublinklist 3->4->5->6 we get, 4->5->6->3. So, our new linked list is 2->4->5->6->3->7.

You need to return the start node of new linked list.

Length of linked list 106

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?