Simple Solution | 99.5 % Beats | Java
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing a count array to say weather an element from head is present in nums or not.\n\n\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing a count array to say weather an element from `head` is present in `nums` or not.\n\n\n# Code\n```java []\nclass Solution {\n    public ListNode modifiedList(int[] nums, ListNode head) {\n        int max = 0;\n        for(int ele : nums) {\n            if(ele > max) max = ele;\n        }\n        int count[] = new int[max + 1];\n        for(int ele : nums) count[ele] = 1;\n\n        ListNode prev = new ListNode(0);\n        prev.next = head;\n        ListNode result = prev;\n        while(head != null) {\n            if(head.val <= max && count[head.val] == 1) {\n                prev.next = head.next;\n                head = head.next;\n            }\n            else {\n                prev = head;\n                head = head.next;\n            }\n        }\n        return result.next;\n    }\n}\n```
['Java']