• + 0 comments

    Simple JAVA approach

    public static Node insert(Node head,int data) {

        if(head==null){
            head = new Node(data);
        }
        else{
            Node start = head;
            while(start.next != null){
            start = start.next;
        }
    
        Node newNode = new Node(data);
        start.next = newNode;
        }
        return head;
    }