# Leetcode 83 Linked-list delete duplicate value #### 基本上LeetCode 已規範好 Linked_node使用不用自己寫 My Solution 時間O(n) 空間 O(1) --- ``` python= def deleteDuplicates(self, head: ListNode) -> ListNode: current = head prev = current while current: if current.val == prev.val: ## 兩個相等 prev.next = current.next # 前一個連結至 current 後一個,但prev停留 else: ## 不相等, prev 更新為 current prev = current current = current.next return head ``` ###### tags: `LeetCode` `linked list` `node` `duplicate`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up