public ListNode rotateRightII(ListNode head, int n) {
		int length = 0;
		ListNode newHead = null, prevNewHead = null, end = null;
		for (ListNode node = head; node != null; node = node.next) {
			if (node.next == null) {
				end = node;
			}
			length++;
		}
		if (length < 2 || n == 0 || n % length == 0) {
			return head;
		}
		ListNode node = head;
		for (int i = 0; i < length - n % length - 1; i++) {
			node = node.next;
		}
		prevNewHead = node;
		newHead = prevNewHead.next;
		prevNewHead.next = null;
		end.next = head;
		return newHead != null ? newHead : head;
	}