Remove Duplicates from a List
Updated
Problem statement
Given an integer array nums in which some values may appear more than once, return a new array that holds every distinct value of nums exactly once.
Keep the values in the order of their first appearance in nums.
Function
uniqueList(nums: int[]) → int[]Examples
Example 1
nums = [8,3,8,5,3,3,1]return = [8,3,5,1]The values first appear in the order 8, 3, 5, 1. The second 8 and the second and third 3 are copies of values already kept, so they are left out.
Example 2
nums = [-2,-2,-2]return = [-2]All three entries hold the same value, so it is kept once.
Example 3
nums = [4,0,-7,9]return = [4,0,-7,9]No value repeats, so every value is kept, in the same order.
Constraints
1 <= nums.length <= 5000-10^4 <= nums[i] <= 10^4
More Bank of America Online Assessment questions
- Return Exact Cash Register ChangeOA · Seen Aug 2026
- Sum Skipping Multiples of 7OA · Seen Nov 2025
- Wildcard Substring MatchOA · Seen Nov 2025
- Maximum String BeautyOA · Seen Sep 2024
- Merge Point of Two Linked ListsOA · Seen Oct 2023
- Pairs with Target Sum in a Sorted ArrayOA · Seen Oct 2023
- Count Level-Order Traversals of a TreeOA · Seen Sep 2023
- Count Set BitsOA · Seen Sep 2023
- Count Pairs with Sum KOA · Seen Jun 2023
- Letter Pattern SumOA · Seen Sep 2022
Similar questions at other companies
- 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
- K Most Recent Unique Request IDsMicrosoft · OAMicrosoft interview questions
- Distinct Products After Removing One ElementHSBC · OAHSBC interview questions