《CITI》P117
2 鏈表
題目:
2.1 Write code to remove duplicates from an unsorted linked list.
FOLLOW UP
How would you solve this problem if a temporary buffer is not allowed?
2.1 Write code to remove duplicates from an unsorted linked list.
FOLLOW UP
How would you solve this problem if a temporary buffer is not allowed?
class SinglyLinkedList: """管理單向鏈表的基本類(使用頭結點)""" class _Node: __slots__ = "value", "next" # 因爲會創建很
class DoublyLinkedBase: """管理雙向鏈表的基本類(使用雙側哨兵結點)""" class _Node: __slots__ = "value", "prev", "next
單鏈表的基本操作(包含頭結點的單鏈表) # 單鏈表結點類 class ListNode: def __init__(self, val): self.val = val self.next