# Definition for singly-link list class ListNode: def __init__(self, val): self.val = val self.next = None