Error in code to remove duplicates from unsorted linked list

My code to remove duplicates from unsorted linked list is giving me wrong answer.I have tried dry running it but still can’t find any error

Problem link:

Code:

Node * removeDuplicates( Node *head) 
    {
        set<int> st;
        Node* temp=head->next;
        Node* newhead=new Node(head->data);
        Node* newtemp=newhead;
        st.insert(head->data);
        while(temp!=NULL)
        {
            if(temp->data==*st.find(temp->data))
            {
                temp=temp->next;
                continue;
            }
            newtemp->next=new Node(temp->data);
            newtemp=newtemp->next;
            st.insert(temp->data);
            temp=temp->next;
            
        }
        return newhead;
    }

//Corrected Code

Node * removeDuplicates( Node *head)
{

    set<int> st;
    Node* temp=head->next;
    Node* newhead=new Node(head->data);
    Node* newtemp=newhead;
    st.insert(head->data);
    while(temp!=NULL)
    {
        if(st.find(temp->data)!=st.end())
        {
            temp=temp->next;
            continue;
        }
        newtemp->next=new Node(temp->data);
        newtemp=newtemp->next;
        st.insert(temp->data);
        temp=temp->next;
        
    }
    return newhead;
}

What is this ???

            if(temp->data==*st.find(temp->data))

Use corret syntax …

 if(st.find(temp->data)!=st.end())

what’s the mistake in this?
if st.find returns a iterator which is not poining to a value temp->data then it should execute the statement