<filename>leetCode/algorithms/easy/remove_linked_list_elements.py<gh_stars>10-100
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


class Solution:
    def removeElements(self, head, val):
        res = p = ListNode(0)
        res.next = head
        while p.next is not None:
            if p.next.val == val:
                p.next = p.next.next
            else:
                p = p.next
        return res.next
