public static ListNode reverseKGroup(ListNode head, int k) {
    	ListNode h = null;
    	ListNode t = null;
    	ListNode lt = null;
    	ListNode p = head;
    	ListNode q = null;
    	ListNode hres = null;
    	int n = k;
    	while (null != p) {
    		t = p;
    		h = null;
	    	while (null != p && n > 0) {
	    		q = p;
	    		p = p.next;
	    		q.next = h;
	    		h = q;
	    		n--;
	    	}
	    	if (0 == n) {
		    	if (null == hres) hres = h; 
		    	if (null != lt) lt.next = h;
		    	lt = t;
		    	t.next = p;
		    	n = k;
	    	} else {
	    		p = h;
	    		q = null;
	    		h = null;
	    		while (null != p) {
	    			q = p.next;
	    			p.next = h;
	    			h = p;
	    			p = q;
	    		}
	    		if (null != lt) lt.next = h;
	    		if (null == hres) hres = h;
	    	}
    	}
        return hres;
    }