83. Remove Duplicates from Sorted List
1. Description
Given a sorted linked list, delete all duplicates such that each element appear only once.
2. Example
Example 1
Input: 1->1->2
Output: 1->2
Example 2
Input: 1->1->2->3->3
Output: 1->2->3
3. Solutions
Linked List
n is the number of nodes in m_head
Time complexity: O(n)
Space complexity: O(1)
| |