You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: solution/0000-0099/0083.Remove Duplicates from Sorted List/README_EN.md
+76-24
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,14 @@
32
32
33
33
## Solutions
34
34
35
+
**Solution 1: Single Pass**
36
+
37
+
We use a pointer $cur$ to traverse the linked list. If the element corresponding to the current $cur$ is the same as the element corresponding to $cur.next$, we set the $next$ pointer of $cur$ to point to the next node of $cur.next$. Otherwise, it means that the element corresponding to $cur$ in the linked list is not duplicated, so we can move the $cur$ pointer to the next node.
38
+
39
+
After the traversal ends, return the head node of the linked list.
40
+
41
+
The time complexity is $O(n)$, where $n$ is the length of the linked list. The space complexity is $O(1)$.
0 commit comments