• + 0 comments

    Easiest Solution with c#

    just remove the Class and public The final solution is:

    static SinglyLinkedListNode reverse(SinglyLinkedListNode llist)
        {
        SinglyLinkedListNode curr = llist;
        SinglyLinkedListNode prev = null;
        SinglyLinkedListNode next = null;
        
        while(curr!= null)
        {
            next = curr.next; //firstly initialising next to its exact location
            curr.next = prev;//reversing the link
            prev=curr; //will move prev by +1
    
        curr = next;//will move curr by +1  
    }
    return prev;
    }