public ListNode reverseKGroup(ListNode head, int k) {
        if(k == 1 || k == 0 || head == null) {
            return head;
        }

        ListNode lastTail = null, ret = head;

        ListNode[] points = new ListNode[k];

        while(true) {
            int leftLen = 0;
            for(; leftLen < k; leftLen++) {
                if(head == null) {
                    break;
                }
                points[leftLen] = head;
                head = head.next;
            }

            if(leftLen < k) {
                break;
            }

            points[0].next = points[k-1].next;
            for(int i = k-1; i > 0; i--) {
                points[i].next = points[i-1];
            }

            if(lastTail == null) {
                ret = points[k-1];
            } else {
                lastTail.next = points[k-1];
            }

            lastTail = points[0];

        }

        return ret;
    }