from typing import Optional from utils import ListNode, list_to_linklist def deleteDuplicates(head: Optional[ListNode]) -> Optional[ListNode]: lens = 0 p = head while p: lens += 1 p = p.next return lens print(deleteDuplicates(list_to_linklist([1, 2, 3, 6, 8])))