Input (num = 3)
1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10
Output
3 -> 2 -> 1 -> 6 -> 5 -> 4 -> 9 -> 8 -> 7 -> 10
public static LinkedListNode reverseWhole(LinkedListNode head, int num) {
if (head == null || head.next == null)
return head;
LinkedListNode[] headAndTail = reversePart(head, num);
LinkedListNode newHead = headAndTail[0];
LinkedListNode tail = headAndTail[1];
LinkedListNode next = tail....