✅ One Line Solution
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: O(n). S
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n    def modifiedList(self, a: List[int], h: Optional[ListNode]) -> Optional[ListNode]:\n        return (f:=lambda n,a={*a}:n and (f(n.next) if n.val in a else ListNode(n.val,f(n.next))))(h)\n```\n\n# Code #1.2 - Unwrapped\n```python3\nclass Solution:\n    def modifiedList(self, a: List[int], h: Optional[ListNode]) -> Optional[ListNode]:\n        def f(node, a={*a}):\n            if node:\n                if node.val in a:\n                    return f(node.next)\n                \n                return ListNode(node.val, f(node.next))\n        \n        return f(h)\n```\n\n# Code #2 - Shorter Version\nTime complexity: $$O(n)$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n    def modifiedList(self, a: List[int], h: Optional[ListNode]) -> Optional[ListNode]:\n        return (f:=lambda n,a={*a}:n and (ListNode(n.val,q:=f(n.next)),q)[n.val in a])(h)\n```\n\n(Disclaimer 2: code above is just a product of fantasy packed into one line, it is not claimed to be \'true\' oneliners - please, remind about drawbacks only if you know how to make it better)
['Linked List', 'Python', 'Python3']