since you have not provided the code of the linked list, I am assuming that the linked list is represented using the node defintion:
class Node:
def __init__(self, data):
self.data = data
self.next = None
CODE
def duplicates(lst, m):
seen = [False for i in range(0, m + 1)]
temp = lst.head
while (temp):
if (seen[temp.data] is True):
print("This list has duplicates")
return
seen[temp.data] = True
print("This list does not have duplicates")
Get Answers For Free
Most questions answered within 1 hours.