Remove Duplicates While Preserving Order
Updated
Problem statement
You are given an integer array values.
Remove duplicate occurrences so that each distinct value appears exactly once. Preserve the order of first appearance.
Return the resulting array.
Function
removeDuplicatesPreservingOrder(values: int[]) → int[]Examples
Example 1
values = [1,1,3,2,1,4,5,4]return = [1,3,2,4,5]Keep the first occurrences of 1, 3, 2, 4, and 5 in their original order.
Example 2
values = [1,2,3]return = [1,2,3]Every value is already distinct.
Example 3
values = [-1,-1,0,-1]return = [-1,0]Keep the first -1 and the first 0.
Constraints
1 <= values.length <= 10^5.-10^6 <= values[i] <= 10^6.
More Wells Fargo Online Assessment questions
- Server Upgrade PlanningOA · Seen Nov 2026
- Student and Course EnrollmentOA · Seen Nov 2026
- Bond Interest Summary Above 3%OA · Seen Oct 2026
- Count Phrases Formed by Anagram ReplacementOA · Seen Oct 2026
- Event Statistics AggregatorOA · Seen Sep 2026
- Ordered Deployment Configuration ValidatorOA · Seen Sep 2026
- Longest Subsequence That Is a SubstringOA · Seen Jul 2026
- Overloaded Game Account InventoriesOA · Seen Jul 2026
- Count Server ReplacementsOA · PHONE SCREEN · Seen Feb 2026
- Minimum Remaining LengthOA · PHONE SCREEN · Seen Feb 2026
Similar questions at other companies
- Build the Task HierarchyPendo · OA
- Macaron Order with Set DiscountsShopify · OAShopify interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Two SumAmazon · OA · PHONE SCREEN
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Customer Signer ScreeningState Farm · OA
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions