input: Write a function to delete a node from a linked list.
  assert to_list(deleteNode(to_linked_list([1, 2, 3, 4, 5]), 3)) == [1, 2, 4, 5]
  assert to_list(deleteNode(to_linked_list([1, 2, 3, 4, 5]), 1)) == [2, 3, 4, 5]
  assert to_list(deleteNode(to_linked_list([1, 2, 3, 4, 5]), 5)) == [1, 2, 3, 4]
output: class ListNode:
      def __init__(self, x):
          self.val = x
          self.next = None
  
  def deleteNode(head, val):
      dummy = ListNode(0)
      dummy.next = head
      prev, curr = dummy, head
  
      while curr:
          if curr.val == val:
              prev.next = curr.next
              break
          prev = curr
          curr = curr.next
  
      return dummy.next
  
  def to_linked_list(lst):
      if not lst:
          return None
      head = ListNode(lst[0])
      current = head
      for value in lst[1:]:
          current.next = ListNode(value)
          current = current.next
      return head
  
  def to_list(node):
      lst = []
      current = node
      while current:
          lst.append(current.val)
          current = current.next
      return lst