kucheasysa

Algoverse_adesh_45

Jul 13th, 2024
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. # Node Class
  2.     ''' class Node:
  3.             def __init__(self, data):   # data -> value stored in node
  4.                 self.data = data
  5.                 self.next = None
  6.                 self.prev = None
  7. '''
  8. class Solution:
  9.     #Function to remove duplicates from unsorted linked list.
  10.     def removeDuplicates(self, head):
  11.         # code here
  12.         current = head
  13.         while current:
  14.             while current and current.next and current.data == current.next.data:
  15.                 current.next = current.next.next
  16.             current = current.next
  17.         return head
  18.  
  19.  
  20.         # return head after editing list
Advertisement
Add Comment
Please, Sign In to add comment