Oms java solution


  • 3
    L
    public class Solution {
    public ListNode swapPairs(ListNode head) {
        if(head==null||head.next==null) return head;
        ListNode tail=head.next.next;
        ListNode newHead=head.next;
        newHead.next=head;
        head.next=swapPairs(tail);
        return newHead;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.