100% beats java solution🔥👍 Easy Explain Basic !!!!
Intuition\nThis Question is based on the problem delete a node from a linked list But the Actual Problem is there are a lot more nodes to be deleted.\n\n# Appro
# Intuition\nThis Question is based on the problem delete a node from a linked list But the Actual Problem is there are a lot more nodes to be deleted.\n\n# Approach\nSo, if we can acces the nodes that we what to delete, the time complexity wiol be reduced, i.e take a node from the array and check in the Linked list and then performing a delete operation will take O(n^2) so to reduce we use a HashSet \n\n* while trvering the LinkedList we are going to chech the next value is avialble in the nodes that we want to delete from our list\n* if we found then we are supposed to skip that node\n\n# Complexity\n- Time complexity:$$O(n)$$ \n- Space complexity:$$O(n)$$ at worst case At an average<$$O(n)$$\n\n# Code\n```\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        HashSet<Integer> st = new HashSet<>();\n        for(int x:nums) st.add(x);\n        // ListNode head=null;\n        // ListNode tail=null;\n        ListNode ptr=head;\n        while(ptr!=null && st.contains(ptr.val))\n        {\n            ptr=ptr.next;\n        }\n        head=ptr;\n        while(ptr!=null && ptr.next!=null)\n        {\n            while(ptr.next!=null && st.contains(ptr.next.val)){\n                ptr.next=ptr.next.next;\n            }\n            ptr=ptr.next;\n        }\n        return head;\n\n\n    }\n}\n```
['Java']