FastPrepFilter Duplicates While Preserving Order
Problems/Filter Duplicates While Preserving Order

Filter Duplicates While Preserving Order

Upstart logoUpstart● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Our version is about 99% the same as the reported question.

Given an integer array data, return a new array containing each distinct value exactly once.

Preserve the order of first appearance: when a value occurs multiple times, keep only its earliest occurrence.

Function

filterDuplicates(data: int[]) → int[]

Examples

Example 1

data = [7,6,4,3,3,4,9]return = [7,6,4,3,9]

The second 3 and second 4 are removed. Every retained value stays in its first-appearance position.

Example 2

data = [5,5,5]return = [5]

Only the first occurrence of 5 is retained.

Example 3

data = [-2,0,-2,4,0]return = [-2,0,4]

Negative values and zero follow the same first-occurrence rule.

Constraints

  • data is not null.
  • Every element of data is an integer.

More Upstart Online Assessment questions

  • Buffet Day GainsOA · Seen Sep 2026
  • Case-Insensitive Anagram CheckOA · Seen Sep 2026
  • Scale Ingredient QuantitiesOA · Seen Sep 2026
  • ABO Parent Genotype CombinationsOA · Seen Aug 2026
  • Chunked Byte Stream ChecksumsOA · Seen Aug 2026
  • Cluster Size on DiskOA · Seen Aug 2026
  • Double Substitution DecryptionOA · Seen Aug 2026
  • Add Drama to Text GroupsOA · Seen Jul 2026
  • Lexicographic Word FrequenciesOA · Seen Jul 2026
  • Minimum Absolute Pair DifferenceOA · Seen Jul 2026

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
All Upstart interview questionsSee Upstart hiring insights
Saved
class Solution {
    public int[] filterDuplicates(int[] data) {
        // write your code here
    }
}
Checking account…