Anyone can help me with my wrong answer?


  • 0
    C

    Anyone can help me with my wrong answer solution? I just make a new List.
    ’‘’
    public class Solution {
    public ListNode reverseList(ListNode Head) {
    ListNode newHead = null;
    ListNode newNext = null;
    while(Head != null){
    newNext = newHead;
    newHead = Head;
    newHead.next = newNext;
    Head = Head.next;
    }
    return newHead;
    }
    }
    ‘’‘


Log in to reply
 

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