Very easy to do, just shifting of pointer once


#1

// just remove the B no. of node from Last and connect as it is to the start of the list.

if(A==NULL||A->next==NULL) return A;

ListNode *last=A,*last2=NULL,*temp=A;
int size=0;
while(temp->next!=NULL){
    size++;
    temp=temp->next;
}
size++;   //bcz last node not counted in while loop.
int r = B%size;  // for fixing the rotation greater than the List size.
if(r==0) return A;
int n=size-r;
while(n>1){
    last=last->next;
    //last2=last2->next;
    n--;
}
last2=last->next;
last->next=NULL;
temp->next=A;

return last2;