easy java,python,c++||clean code||easy to understand
Intuition :Given that Nodes must be removed from a linked list where the node values should equal to nums list given  Because the list of values \u200B\u200B(nu
**Intuition** :Given that Nodes must be removed from a linked list where the node values should equal to nums list given  Because the list of values \u200B\u200B(nums) is so large, it would be inefficient to check if the value of each node is in this list. To best deal with this, use the set.\n**Aprroach**:\napproach used by me is given below\n1. **Convert `nums` to a Set**: \n   - Create a set from the `nums_set` from \'nums\' list. This makes it fast and easy to check if a node\u2019s value should be removed.\n2. **Create a Dummy Node**: \n   - Add a dummy node at the beginning of the linked list. This dummy node helps handle cases where the first node might need to be removed.\n3. **Use Two Pointers**:\n   - **`prev` Pointer**: Keeps track of the node right before the current node.\n   - **`current` Pointer**: Moves through the linked list from start to end.\n4. **Iterate Through the List**:\n   - For each node, check if its value is in the set of values to be removed.\n   - If the node\u2019s value is in the set, remove it by making `prev` skip over this node.\n   - If the node\u2019s value is not in the set, move the `prev` pointer to this node.\n5. **Return the Updated List**: \n   - After processing all nodes, return the list starting from the node after the dummy node.\n![image](https://assets.leetcode.com/users/images/7325bc00-a7e9-468b-88f5-07fa21404cdd_1724161332.0800798.jpeg)\n\n\n```\nimport java.util.HashSet;\nimport java.util.Set;\nclass Solution {\n    public ListNode modifiedList(int[] nums, ListNode head) {\n        Set<Integer> numsSet = new HashSet<>();\n        for (int num : nums) {\n            numsSet.add(num);\n        }\n        ListNode dummy = new ListNode(-1);\n        dummy.next = head;\n        ListNode prev = dummy;\n        ListNode current = head;\n        while (current != null) {\n            if (numsSet.contains(current.val)) {\n                prev.next = current.next;\n            } else {\n                prev = current;\n            }\n            current = current.next;\n        }\n        return dummy.next;\n    }\n}\n```\n\n```\nclass Solution:\n    def modifiedList(self, nums: List[int], head: Optional[ListNode]) -> Optional[ListNode]:\n        nums_set=set(nums)\n        dummy=ListNode(-1)\n        dummy.next=head\n        prev=dummy\n        current=head\n        while current:\n            if current.val in nums_set:\n                prev.next=current.next\n            else:\n                prev=current\n            current=current.next\n        return dummy.next    \n```\n\n```\n#include <unordered_set>\n#include <vector>\nclass Solution {\npublic:\n    ListNode* modifiedList(std::vector<int>& nums, ListNode* head) {\n        std::unordered_set<int> nums_set(nums.begin(), nums.end());\n        ListNode dummy(-1);\n        dummy.next = head;\n        ListNode* prev = &dummy;\n        ListNode* current = head;\n        while (current) {\n            if (nums_set.find(current->val) != nums_set.end()) {\n                prev->next = current->next;\n            } else {\n                prev = current;\n            }\n            current = current->next;\n        }\n        return dummy.next;\n    }\n};\n\n```
['Linked List', 'C', 'Python', 'Java']