203-Remove-Linked-List-Elements
Sat 17 May 2025
https://leetcode.com/problems/remove-linked-list-elements
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def removeElements(self, head: ListNode, val: int) -> ListNode:
dummy = ListNode(0, head)
prev = dummy
while head:
if head.val != val:
prev.next = head
prev = prev.next
head = head.next
prev.next = None
return dummy.next
new Solution().removeElements()
Score: 5
Category: leetcode