Python 3 || 10 lines, list traversal  || T/S: 93% / 70%
Here\'s the plan:\n1. We traverse the linked list and reset head at the first node for which its value is not in nums.\n2. We record this node using ans and con
Here\'s the plan:\n1. We traverse the linked list and reset `head` at the first node for which its value is not in `nums`.\n2. We record this node using `ans` and continue to traverse the linked list. \n3. For each node in the traverse, we "leapfrog" over any number of consecutive, subsequent nodes with values in `nums`. \n4. When we encounter a node with a value not in the list, we move to that node and continue the traverse.\n5. We return `ans` as the head of the revised linked list.\n\n```\nclass Solution:\n    def modifiedList(self, nums: List[int], head: Optional[ListNode]) -> Optional[ListNode]:\n        \n        nums = set(nums)        \n        \n        while head.val in nums:                 # <-- 1)\n            head = head.next\n\n        ans = ListNode(head.val, head)          # <-- 2)\n \n        while head and head.next:               # <-- 3)\n            if head.next.val in nums:\n                head.next = head.next.next\n\n            else:                               # <-- 4)\n                head = head.next\n\n        return ans.next                         # <-- 5)\n\n```\n[https://leetcode.com/problems/delete-nodes-from-linked-list-present-in-array/submissions/1327797714/](https://leetcode.com/problems/delete-nodes-from-linked-list-present-in-array/submissions/1327797714/)\n\nI could be wrong, but I think that time complexity is *O*(*N* + *M*) and space complexity is *O*(*N*), in which *M* ~ the number of nodes in the linked list and *N* ~ `len(nums)`.
['Python', 'Python3']