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;
        
    }

 

posted @ 2019-10-22 21:25  李荣先辈Java  阅读(163)  评论(0编辑  收藏  举报