LeetCode24-Swap_Pairs

swapPairs

 public ListNode swapPairs(ListNode head) {
         if(head==null ||head.next==null) return head;
        
       ListNode temp = head.next;
       head.next = swapPairs(temp.next);
       temp.next = head;
        
       return temp;
        
    }
原文地址:https://www.cnblogs.com/Jomini/p/11722643.html