<reponame>therealmaxkim/Playground<gh_stars>0


#!/bin/python3

import os
import sys

class SinglyLinkedListNode:
    def __init__(self, node_data):
        self.data = node_data
        self.next = None

class SinglyLinkedList:
    def __init__(self):
        self.head = None
        self.tail = None

    def insert_node(self, node_data):
        node = SinglyLinkedListNode(node_data)

        if not self.head:
            self.head = node
        else:
            self.tail.next = node


        self.tail = node

def print_singly_linked_list(node, sep, fptr):
    while node:
        fptr.write(str(node.data))

        node = node.next

        if node:
            fptr.write(sep)

# Complete the compare_lists function below.

#
# For your reference:
#
# SinglyLinkedListNode:
#     int data
#     SinglyLinkedListNode next
#
#
'''

1 ->    2 ->    3 ->    None

1 ->    2 ->    None

have two pointers. Check that they are same value. Keep moving to next.

'''
def compare_lists(llist1, llist2):
    while llist1 != None and llist2 != None:
        if llist1.data != llist2.data:
            return 0
        llist1 = llist1.next
        llist2 = llist2.next
    
    #both points should be at None. If not, the lists are not the same length
    if llist1 == None and llist2 == None:
        return 1
    else:
        return 0
