@@ -0,0 +1,1667 @@
+package leetcode.reverse_nodes_in_k_group;%0A%0Aimport common.ListNode;%0A%0Apublic class Solution %7B%0A    public ListNode reverseKGroup(ListNode head, int k) %7B%0A        if(head == null %7C%7C k %3C= 1) return head;%0A        %0A        ListNode prev = null;%0A        while(true)%7B%0A        %09ListNode groupHead;%0A        %09if(prev == null)%7B%0A        %09%09groupHead = head;%0A        %09%7Delse%7B%0A        %09%09groupHead = prev.next;%0A        %09%7D%0A        %09if(groupHead == null) return head;%0A        %09ListNode groupTail = groupHead;%0A        %09int steps;%0A        %09for(steps = 0; steps %3C k - 1 && groupTail.next != null; steps++)%7B%0A        %09%09groupTail = groupTail.next;%0A        %09%7D%0A        %09if(steps %3C k - 1) return head;%0A        %09else%7B%0A        %09%09ListNode groupNext = groupHead.next;%0A        %09%09ListNode groupPrev = groupHead;%0A        %09%09for(int i = 0; i %3C k - 1; i++)%7B%0A        %09%09%09ListNode groupTmp = groupNext.next;%0A        %09%09%09groupNext.next = groupHead;%0A        %09%09%09groupPrev.next = groupTmp;%0A        %09%09%09groupHead = groupNext;%0A        %09%09%09groupTail = groupPrev;%0A        %09%09%09groupNext = groupTmp;%0A        %09%09%7D%0A        %09%09if(prev == null)%7B%0A        %09%09%09head = groupHead;%0A        %09%09%7Delse%7B%0A        %09%09%09prev.next = groupHead;%0A        %09%09%7D%0A        %09%09prev = groupTail;%0A        %09%7D%0A        %7D%0A    %7D%0A    %0A    public static void dump(ListNode head)%7B%0A    %09while(head != null)%7B%0A    %09%09System.err.print(head.val + %22-%3E%22);%0A    %09%09head = head.next;%0A    %09%7D%0A    %7D%0A    public static void main(String%5B%5D args)%7B%0A    %09final int N = 3;%0A    %09ListNode%5B%5D list = new ListNode%5BN%5D;%0A    %09for(int i = 0; i %3C N; i++)%7B%0A    %09%09list%5Bi%5D = new ListNode(i);%0A    %09%09if(i %3E 0) list%5Bi - 1%5D.next = list%5Bi%5D;%0A    %09%7D%0A    %09dump(new Solution().reverseKGroup(list%5B0%5D, 4));%0A    %7D%0A%7D%0A

Add java solution for 25. Reverse Nodes in k-Group