public ListNode rotateRight(ListNode head, int k) {
        if (head == null) return null;
        if (k == 0) return head;

        ListNode cur = head;
        int count = 1;

        // count total
        while (cur.next != null) {
            cur = cur.next;
            count++;
        }

        //point tail to head
        cur.next = head;
        k = k % count;


        cur = head;
        int i = 1;
        int j = count - k;
        while (i < j) {
            cur = cur.next;
            i++;
        }

        ListNode result = cur.next;
        cur.next = null;
        return result;
    }