k 是一个正整数，它的值小于或等于链表的长度。如果节点总数不是 k 的整数倍，那么请将最后剩余的节点保持原有顺序。

class Solution {    public ListNode reverseKGroup(ListNode head, int k) {        if(head == null || head.next == null)        return head;        ListNode dummyHead = new ListNode(0);        dummyHead.next = head;        ListNode cur = head;        int count = 0;        while(cur != null)        {            cur = cur.next;            count++;        }            int timesToFlip = count / k;        cur= head;        ListNode before = dummyHead;        ListNode after  = null;        for(int i = 0; i < timesToFlip; i++)        {            int numNodes = k;             ListNode temp = null, pre = null;                        //Reverse partial Linked-list            while(numNodes != 0)            {                numNodes--;                temp = cur.next;                cur.next = pre;                pre = cur;                cur = temp;                after = cur;             }                  before.next = pre;            while(pre.next != null)                pre = pre.next;            pre.next = after;            before = pre;            cur = before.next;        }        return dummyHead.next;    }}