easy solution in c++.
IntuitionApproachComplexity
Time complexity:O(n)

Space complexity:O(n)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* modifiedList(vector<int>& nums, ListNode* head) {
        unordered_map<int,bool> m;
        for(int i=0;i<nums.size();i++)
        {
            m[nums[i]]=true;
        }
        ListNode *prev=NULL;
        ListNode *h=NULL;
        while(head != NULL)
        {
            if(m.count(head->val) == 0)
            {
                ListNode *s=head->next;
                head->next=NULL;
                if(prev == NULL)
                {
                    prev=head;
                    h=head;
                }
                else
                {
                    prev->next=head;
                    prev=head;
                }
                head=s;
            }
            else
            {
                head=head->next;
            }
        }
        return h;
    }
};
```
['Array', 'Hash Table', 'Linked List', 'C++']