You are viewing a single comment's thread. Return to all comments →
Here is a general solution because I didn't read the entire specification 🤡
def removeDuplicates(self,head): head_data = head.data result_head = Node(head_data) previous_result_node = result_head elements = list() elements.append(head_data) node = head.next while node is not None: node_data = node.data if node_data not in elements: result_node = Node(node_data) previous_result_node.next = result_node previous_result_node = result_node elements.append(node_data) node = node.next return result_head
Seems like cookies are disabled on this browser, please enable them to open this website
Day 24: More Linked Lists
You are viewing a single comment's thread. Return to all comments →
Here is a general solution because I didn't read the entire specification 🤡