public static ListNode reverseKGroup(ListNode head, int k) {
        if (head == null)
            return head;
            
        ListNode dummy = new ListNode(-1, null);
        ListNode current = dummy;
        dummy.next = head;
        
        while(true) {
            ListNode indexer = current.next;
            int i = 0;
            for (i = 0; i < k && indexer != null; i++)
                indexer = indexer.next;

            if (indexer == null && i < k)
                break;

            ListNode swapper = current.next; 

            while (swapper.next != indexer) {
                ListNode next = swapper.next;
                ListNode curNext = current.next;
                current.next = next;
                swapper.next = next.next;
                next.next = curNext;
            }
            
            current = swapper;
        }
        
        return dummy.next;
    }