FastPrepTrack New Values in Sorted Order
Problems/Track New Values in Sorted Order

Track New Values in Sorted Order

Bloomberg LP logoBloomberg LP● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Bloomberg asked this in a technical phone screen with a second team. The task was a class whose add method takes an integer, says whether it was seen before, and returns all values seen so far in sorted order without repeats. The interviewer then pushed on memory use when add is called very many times, and the candidate discussed a bit set over the value range.

The report gave the behavior by example, but no value range, call count or exact output shape. Our choices here: the calls are given as an array processed in order, starting from an empty structure. Each call's result is one row starting with new or old, followed by the sorted different values as strings. Values are integers from 0 to 999 and there are 1 to 50 calls, which keeps the full sorted list in every row small.

Our version is about 85% the same as the reported question.

Design a structure with one operation, add(x), which stores the integer x. Each call returns two things: whether x is "new" (never added before) or "old" (added by an earlier call), and all distinct values stored so far, in ascending order, after this call.

You are given values, where values[i] is the argument of the i-th call to add, starting from an empty structure. Return one row per call: the row starts with "new" or "old", followed by the stored distinct values in ascending numeric order, each written as a decimal string.

Function

trackAdds(values: int[]) → String[][]

Examples

Example 1

values = [2,1,2,3,1]return = [["new","2"],["new","1","2"],["old","1","2"],["new","1","2","3"],["old","1","2","3"]]
  • add(2): 2 is new, the values are [2].
  • add(1): new, [1, 2].
  • add(2): 2 was already added, so it is old; the values stay [1, 2].
  • add(3): new, [1, 2, 3].
  • add(1): old, [1, 2, 3].

Example 2

values = [7]return = [["new","7"]]
  • The only call adds a new value, so the result is one row: ["new", "7"].

Example 3

values = [5,5,5]return = [["new","5"],["old","5"],["old","5"]]
  • The first add(5) is new; the next two are old. The values stay [5].

Constraints

  • 1 <= values.length <= 50
  • 0 <= values[i] <= 999

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Employee Ratings Management SystemAmazon · PHONE SCREEN
  • Running Medians and PercentilesStackAdapt · PHONE SCREENStackAdapt interview questions
  • Versioned ArrayTrueFoundry · PHONE SCREEN
  • My Calendar IUber · ONSITE INTERVIEWUber interview questions
  • Future-Effective Employee SalaryRippling · ONSITE INTERVIEWRippling interview questions
  • Chronological Sliding-Window Request CounterCareem · ONSITE INTERVIEWCareem interview questions
  • Run-Length Integer Map: Get and SetAdobe · OAAdobe interview questions
  • Array-Backed Set Without Library CollectionsOde with Anthropic · PHONE SCREEN
  • Price at Query TimestampsGoogle · PHONE SCREENGoogle interview questions
  • First Missing Number in a Consecutive ArrayArista Networks · OA · PHONE SCREENArista Networks interview questions

Interview reports that mention this question

  • Bloomberg SWE Phone Screens with Two Teams: 1 Experience

Bloomberg LP interview experiences

  • Bloomberg SWE Phone Screen and Onsite: 1 Experience
  • Bloomberg AI Interview, Hiring Level Not Reported: 2 Experiences
  • Bloomberg Experienced SWE AI Coding Interviews: 2 Experiences
  • Bloomberg New Grad AI-Assisted Coding Rounds: 3 Experiences
  • Bloomberg New Grad SWE AI-Assisted Coding Rounds: 1 Experience
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[][] trackAdds(int[] values) {
        // Write your code here.
    }
}
Checking account…