Remove Repeated Values from a Sorted List
Updated
Problem statement
Given a sorted linked list, remove every node whose value occurs more than once. Keep only values that occur exactly once, in their original order, and return the remaining head.
A repeated group is removed entirely; do not keep one representative. Return null, serialized as [], when no node remains.
Function
removeRepeatedValues(head: ListNode) → ListNodeExamples
Example 1
head = [1,2,3,3,4,4,5]return = [1,2,5]Removed
Moved or new
Both 3 nodes and both 4 nodes are removed.
Example 2
head = [1,1,1,2,3]return = [2,3]Removed
Moved or new
All three 1 nodes are removed, including the old head.
Constraints
0 <= head.length <= 500.-1000000000 <= head[i] <= 1000000000.- The input is an acyclic linked list in nondecreasing value order.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Remove Nth Node From End of ListDruva · ONSITE INTERVIEW
- Find the Entry of a Linked List CycleQualys · ONSITE INTERVIEWQualys interview questions
- Detect a Linked-List CyclePaytm · ONSITE INTERVIEWPaytm interview questions
- Detect a Linked-List CycleCapgemini · ONSITE INTERVIEWCapgemini interview questions
- Rearrange a Linked List from Alternating EndsConcentric AI · ONSITE INTERVIEWConcentric AI interview questions
- Palindrome Linked List with RestorationMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Linked List Cycle Entry NodeGoogle · ONSITE INTERVIEWGoogle interview questions
- Detect and Break a Linked-List CycleAmazon · ONSITE INTERVIEW
- Odd-Even Linked ListBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Find the Entry of a Linked List CyclePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)