Easy Video Solution 🔥 || How to 🤔 in Interview || Using Temp Node ✅
If you like the solution Please Upvote and subscribe to my youtube channel\n\n\n\nEasy Video Explanation\n\nhttps://youtu.be/LHe2bHokebc\n\n    \n\n# Code\n\n\n
***If you like the solution Please Upvote and subscribe to my youtube channel***\n\n\n\n***Easy Video Explanation***\n\nhttps://youtu.be/LHe2bHokebc\n\n    \n\n# Code\n\n\n```C++ []\nclass Solution {\npublic:\n    ListNode* modifiedList(vector<int>& v, ListNode* head) {\n        ListNode *d= new ListNode(-1);\n        ListNode *t=d;\n        set<int>s;\n        for(auto i:v)\n            s.insert(i);\n        while(head!=NULL) {\n            if(s.find(head->val)==s.end()) {\n                t->next=head;\n                t=t->next;\n            }\n            head=head->next;\n        }\n        t->next=NULL;\n        return d->next;\n    }\n};\n```\n```python []\nclass Solution:\n    def modifiedList(self, v, head):\n        dummy = ListNode(-1)\n        t = dummy\n        s = set(v)\n        \n        while head:\n            if head.val not in s:\n                t.next = head\n                t = t.next\n            head = head.next\n        \n        t.next = None\n        return dummy.next\n```\n```Java []\nclass Solution {\n    public ListNode modifiedList(List<Integer> v, ListNode head) {\n        ListNode dummy = new ListNode(-1);\n        ListNode t = dummy;\n        Set<Integer> s = new HashSet<>(v);\n        \n        while (head != null) {\n            if (!s.contains(head.val)) {\n                t.next = head;\n                t = t.next;\n            }\n            head = head.next;\n        }\n        \n        t.next = null;\n        return dummy.next;\n    }\n}\n\n```\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(N*log(N))\n    \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1)\n\n# ***If you like the solution Please Upvote and subscribe to my youtube channel***\n***It Motivates me to record more videos***\n\n*Thank you* \uD83D\uDE00
['Linked List', 'Ordered Set', 'C++', 'Java', 'Python3']