Identical Linked Lists | Problem of the Day | GeeksForGeeks

Поділитися
Вставка
  • Опубліковано 3 жов 2024

КОМЕНТАРІ • 1

  • @mathematics3398
    @mathematics3398  3 місяці тому

    def areIdentical(head1, head2):
    if not head1 and not head2:
    return True
    if not head1 and head2:
    return False
    if head1 and not head2:
    return False
    while head1 and head2:
    if head1.data != head2.data:
    return False
    head1 = head1.next
    head2 = head2.next
    if not head1 and not head2:
    return True
    return False