Simple || Easy to Understand || Clear
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\n/**\n * Definition for singly-linked list.\n * public class ListNode {\n *     int val;\n *     ListNode next;\n *     ListNode() {}\n *     ListNode(int val) { this.val = val; }\n *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }\n * }\n */\nclass Solution {\n    public ListNode modifiedList(int[] nums, ListNode head) {\n\n        HashSet<Integer> set = new HashSet<>();\n\n        for(int x : nums) set.add(x);\n\n        ListNode temp = new ListNode();\n        ListNode res = temp;\n\n        while(head != null) {\n            if(!set.contains(head.val)) {\n                ListNode newNode = new ListNode(head.val);\n                temp.next = newNode;\n                temp = temp.next;\n            }\n            head = head.next;\n        }\n\n        return res.next;\n    }\n}\n```
['Java']