Sliding window python solution :)


#1
def rotateRight(self, head, k):
    length = 0
    cur = head
    res = head
    while cur:
        cur = cur.next
        length+=1
        
    k = k%length
    if k==0:
        return head
        
    front = head
    back = head
    
    while front.next and k>0:
        front = front.next
        k-=1
    
    while back.next and front.next:
        front=front.next
        back = back.next
        
    res = back.next
    back.next = None
    front.next = head
    
    return res