Little busy, but this is just as much a problem as reverse linkedlist.
class Solution {
public ListNode swapPairs(ListNode head) {
// base case
if(head == null || head.next == null) return head;
ListNode last = head.next; // this would be the new head, because we have to reverse curr and next
head.next = swapPairs(head.next.next); // the head is now the curr sections last node and it suppose to connect to the rest of the list
last.next = head; // set the new head to connect to the curr head which is tail of the curr section
return last;
}
}
