Question
Solution
首先创建两个指针:pre, cur。pre指向空,cur指向head。如果出现多个相同元素,cur向后移动直到指向新的元素,pre.next指向cur。如果元素不重叠,pre移到cur的位置,cur向后移动一位。
1 | # Definition for singly-linked list. |
首先创建两个指针:pre, cur。pre指向空,cur指向head。如果出现多个相同元素,cur向后移动直到指向新的元素,pre.next指向cur。如果元素不重叠,pre移到cur的位置,cur向后移动一位。
1 | # Definition for singly-linked list. |