This problem is relatively simple, do not do too much description
Given a sorted list, delete all duplicate elements, leaving only one for each element.
example
give 1->1->2->null
, return 1->2->null
give 1->1->2->3->3->null
, return < Code style= "PADDING:2PX 4px; Color: #c7254e; Font-family:menlo, Monaco, Consolas, "courier New", monospace; font-size:12.6px; White-space:nowrap; Background-color: #f9f2f4 ">1->2->3->null
"" "Definition of Listnodeclass ListNode (object): def __init__ (self, Val, next=none): self.val = val Self.next = Next "" "Class Solution:" " @param: Head:head is the head of the linked list @return: Head of link Ed list "" " def deleteduplicates (self, head): If head was None: return head temp = head while Temp.next is not None: if Temp.next.val = = Temp.val: temp.next = temp.next.next else: temp = Temp.next return head
Delete a repeating element in a sorted list (simple)