class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next Draw It out! To solve the linked list problems, the most important thing is to draw the linked list and the procedure out.
2021-04-15