mirror of
https://github.com/SunnyQjm/algorithm-review.git
synced 2026-06-03 08:16:43 +08:00
Update 3_remove-duplicates-from-sorted-list.py
This commit is contained in:
@@ -37,6 +37,8 @@ class Solution:
|
||||
1. 用两个指针,pre指向当前遍历节点的前一个节点,cur指向当前节点;
|
||||
2. 用last记录上一次访问的数字;
|
||||
3. 每次查看当前值和上一次访问的数字是否相同,相同则执行删除节点操作,不相同则更新last和两个指针
|
||||
|
||||
(讲真,感觉last有点冗余hhh,直接pre.val好像可以替代last)
|
||||
"""
|
||||
if not head:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user