public static ListNode reverseKGroup(ListNode head, int k) {
        if (head == null || k < 2) {
            return head;
        }
        int[] temp = new int[k];
        int step = 0;
        ListNode p = head;
        ListNode q = head;

        while (p != null) {
            int i = step++ % k;
            temp[i] = p.val;

            if (i == k - 1) {
                int j = i;
                while (q != null && j >= 0) {
                    q.val = temp[j--];
                    q = q.next;
                }
            }

            p = p.next;
        }
        return head;
    }