draft.py 298 B

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