Reverse Linked List In Pairs
public LinkedList reverse(ListNode head){
if(head == null){
return null;
}
ListNode tmp = head;
ListNode prev = null;
while(tmp!= null){
ListNode next = tmp.next;
tmp.next = prev;
prev = tmp;
tmp= next;
}
return prev;
}
public ListNode reverse(ListNode head){
if(head == null || head.next == null){
return head;
}
ListNode newHead = reverse(head.next)'
head.next.next = head;
head.next = null;
return newHead;
}