• + 0 comments

    Solution in C#, using recursion:

    public static Node insert(Node head,int data)
    {
        if (head == null)
        {
            head = new Node(data);
            return head;
        }
        var newHead = insert(head.next, data);
    
        head.next= newHead;
    
        return head;
    }