|| How to 🤔 in Interview || Using Temp Node ✅
Please Uovote\uD83D\uDE4C\n Describe your first thoughts on how to solve this problem. \n\n# Approach \uD83E\uDD14\n- use Stream method to convert array to hash
# Please Uovote\uD83D\uDE4C\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach \uD83E\uDD14\n- use Stream method to convert array to hashset.\n- for check node is exist or not use `.contains()` method.\n- after it deleting nodes using temp node. \n\n# Complexity \u23F2\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code \uD83D\uDCBB\n```\n\nclass Solution {\n    public ListNode modifiedList(int[] nums, ListNode head) {\n        HashSet<Integer> list = IntStream.of(nums).boxed()\n    .collect(Collectors.toCollection(HashSet::new));\n        while(list.contains(head.val) && head.next!=null)\n        head = head.next;\n        if(head.next==null || head == null)return head;\n        ListNode h = head.next;\n        ListNode prev = head;\n        \n        while(h!=null){\n            if(list.contains(h.val)){\n                prev.next = prev.next.next;\n                h = prev.next;\n            }\n            else{\n            h = h.next;\n            prev = prev.next;\n            }\n        }\n        return head;\n    }\n}\n```
['C++', 'Java']