easyLinked List 0 views
Remove Duplicates From a Sorted Linked List
Collapse consecutive duplicate values in a sorted singly-linked list so each value appears once.
Given the head of a singly-linked list that is sorted in ascending order, delete all duplicate values so that each value appears only once, and return the resulting sorted list.
Example 1
Input: head = [1,1,2,3,3]
Output: [1,2,3]
Example 2
Input: head = [1,1,1,1]
Output: [1]
Example 3
Input: head = []
Output: []
Explanation: An empty list has no duplicates to remove.
Constraints
- The number of nodes in the list is in the range [0, 300].
- -100 <= Node.val <= 100
- The list is guaranteed to be sorted in ascending order.
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.