FastPrepRemove Duplicates While Preserving Order
Problems/Remove Duplicates While Preserving Order

Remove Duplicates While Preserving Order

Akuna Capital logoAkuna Capital● EasyINTERNFULLTIMENEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Fuller reports ask for removing duplicates while keeping the first occurrences. Some brief accounts only mention checking for duplicates or leave out the output order. We return the distinct values in the order they first appear. We chose limits on the numbers and a rule for empty input. Some rounds asked for a spoken algorithm. String reports get a companion version that takes a string and returns a string, limited to printable ASCII. Keeping first occurrences is our rule when a report leaves out the order. The workspace still grades the integer-array form.

Our version is about 95% the same as the reported questions.

You are given an integer array nums. Return an array containing each distinct value exactly once, in the order of its first occurrence in nums.

The input is not necessarily sorted. Return an empty array when nums is empty.

Function

removeDuplicates(nums: int[]) → int[]

Examples

Example 1

nums = [1,2,2,4,4]return = [1,2,4]

The first occurrences of 1, 2, and 4 are at indices 0, 1, and 3, respectively.

Example 2

nums = [5,4,1,5]return = [5,4,1]

Keep the first 5, then 4 and 1. Ignore the final 5 because that value has already appeared.

Example 3

nums = [5,2,5,1]return = [5,2,1]

Keep 5 and 2, skip the repeated 5, and then keep 1.

Constraints

  • 0 <= nums.length <= 100000
  • -10^9 <= nums[i] <= 10^9

More Akuna Capital Phone Screen questions

  • Match Orders by Price and Arrival TimeOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Biased Coin: Probability of Exactly h HeadsPHONE SCREEN · Seen Nov 2026
  • Positive Nth Root with Gradient DescentPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Two SumOA · PHONE SCREEN · Seen Sep 2026
  • Maximum Value in a Binary TreePHONE SCREEN · Seen Sep 2026
  • Tiered Expiring Item StorePHONE SCREEN · Seen Aug 2026
  • Statistics for the Latest K ValuesPHONE SCREEN · Seen Nov 2025
  • Sliding Window MaximumPHONE SCREEN · Seen Oct 2025
  • Evaluate a PolynomialPHONE SCREEN · Seen Oct 2025
  • Reverse Nodes in Groups of KPHONE SCREEN · Seen Oct 2025

Similar questions at other companies

  • Majority ElementByteDance · PHONE SCREENByteDance interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Find Unique ElementsCisco · PHONE SCREENCisco interview questions
  • Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Two SumAmazon · OA · PHONE SCREEN
  • Employee Count Median, Mean and ModeClay · PHONE SCREEN
  • Two SumBNSF Railway · PHONE SCREENBNSF Railway interview questions
  • List the Key and Value of Every Map EntryNewgen Software · ONSITE INTERVIEW
  • Pizza Price CalculatorMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

Interview reports that mention this question

  • Akuna Capital JQR CodePair Rounds: 8 Experiences (Part 6 of 6)
  • Akuna Capital QR-ML Interviews: 11 Experiences (Part 4 of 6)
  • Akuna Capital QR Regression Rounds: 11 Experiences (Part 3 of 6)
  • Akuna Capital Quant Oral Rounds: 11 Experiences (Part 3 of 3)

Akuna Capital interview experiences

  • Akuna Capital Quant Trader and QR Interviews: 5 Experiences
  • Akuna Capital QR Probability Phones: 14 Experiences (Part 5 of 6)
All Akuna Capital interview questionsSee Akuna Capital hiring insights
Saved
class Solution {
    public int[] removeDuplicates(int[] nums) {
        // write your code here
    }
}
Checking account…