Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Node Class
- ''' class Node:
- def __init__(self, data): # data -> value stored in node
- self.data = data
- self.next = None
- self.prev = None
- '''
- class Solution:
- #Function to remove duplicates from unsorted linked list.
- def removeDuplicates(self, head):
- # code here
- current = head
- while current:
- while current and current.next and current.data == current.next.data:
- current.next = current.next.next
- current = current.next
- return head
- # return head after editing list
Advertisement
Add Comment
Please, Sign In to add comment