Easy C++ O(n) time complexity solution


#1
ListNode* Solution::rotateRight(ListNode* A, int B) {
    ListNode* temp_end = A;
    int length = 0;
    while(temp_end->next != NULL){
        temp_end = temp_end->next;
        length++;
    }
    length++;
    B = B%length;
    for(int i = 0; i<(length - B); i++){
        temp_end->next = A;
        A = A->next;
        temp_end = temp_end->next;
        temp_end->next = NULL;
    }
    return A;
}