Java Solution - Reverse a linked list


#1
public ListNode reverseList(ListNode A) {
    ListNode prev=null, curr=A, next=null;
    while (curr != null) {
        next = curr.next;
        curr.next = prev;
        prev = curr;
        curr = next;
    }
    
    return prev;
}