Memory Limit Exceeded, Any reason ?


  • 0
    A

    public ListNode swapPairs(ListNode head) {
    ListNode result = head;
    ListNode temp = null;
    while(head != null && head.next != null){
    temp = head.next.next;
    head.next.next = head;
    head = temp;
    }
    return result;
    }


Log in to reply
 

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