public ListNode rotateRight(ListNode head, int n) {
        if (head == null || head.next == null) return head;
        if (n == 0) return head;
        ListNode slowPointer = head;
        int countDown = n;
        ListNode fastPointer = head;
        int listLength = 0;
        while (fastPointer.next != null) {
            if (countDown == 0) slowPointer = slowPointer.next;
            else countDown--;
            fastPointer = fastPointer.next;
            listLength++;
        }

        listLength++;
        if (countDown > 0) {
            n = n % listLength;
            if (n == 0) return head;
            countDown = n;
            slowPointer = head;
            fastPointer = head;
            while (fastPointer.next != null) {
                if (countDown == 0) slowPointer = slowPointer.next;
                else countDown--;
                fastPointer = fastPointer.next;
            }

        }

        ListNode newHead = slowPointer.next;
        slowPointer.next = null;
        fastPointer.next = head;
        return newHead;
    }