 C++✅ || Beats 💯|| Hashing Logic🔥 || Simple & Fast Code 🚀 
Intuition 🤔We need to remove nodes from a linked list whose values exist in a given vector.Approach 🚀
Store the values from nums in an unordered_map for quick l
![Screenshot 2025-03-23 133814.png](https://assets.leetcode.com/users/images/bf15522b-4764-41c7-8428-4603afe722b3_1742717365.9096012.png)

# Intuition 🤔  
We need to remove nodes from a linked list whose values exist in a given vector.  

# Approach 🚀  
1. Store the values from `nums` in an **unordered_map** for quick lookup.  
2. Adjust the `head` pointer if initial nodes need to be removed.  
3. Traverse the list and remove nodes whose values exist in the map.  

# Complexity ⏳  
- **Time Complexity:** $$O(n)$$ (Traversing the list once, plus $$O(m)$$ for storing values in the map)  
- **Space Complexity:** $$O(m)$$ (Using an unordered_map for storing values)  

# Code 💻  
```cpp
class Solution {
public:
    ListNode* modifiedList(vector<int>& nums, ListNode* head) {
        unordered_map<int, bool> umap;
        for (int n : nums) umap[n] = true;

        // Adjust head if its value is in nums
        while (head && umap[head->val]) head = head->next;
        
        ListNode* temp = head;
        ListNode* curr = temp;

        while (temp && temp->next) {
            if (umap[temp->next->val]) {
                temp->next = temp->next->next;
            } else {
                temp = temp->next;
            }
        }
        return head;
    }
};
```
![upvote.jpeg](https://assets.leetcode.com/users/images/a5a04fce-6e5e-4c25-a682-b3cd1950140b_1742717342.2483184.jpeg)

['Array', 'Hash Table', 'Linked List', 'C++']