25. Remove Duplicates from Sorted List
Easy
You are given a linked list in ascending order and must return a list containing one occurrence of each value, preserving the order. The list may be empty.
Example 1
Input: head = [1, 1, 2, 4, 4, 4]
Output: [1, 2, 4]
Example 2
Input: head = [-3, -3, -1]
Output: [-3, -1]
Constraints
- 0 <= tamanho da lista <= 10000
- Os valores estão em ordem não decrescente.
Linked listTwo pointers
Saved in this browser
Caso 1
head =
[1,1,2,4,4,4]
Expected =
[1,2,4]
Caso 2
head =
[-3,-3,-1]
Expected =
[-3,-1]
Run checks these 2 cases. Submit runs all 6, including hidden ones.