FastPrepDesign an Ordered Stream
Problems/Design an Ordered Stream

Design an Ordered Stream

Bloomberg LP logoBloomberg LP● EasyNEW GRADFULLTIMEOAPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bloomberg interview for new grad and full-time roles. The report names Design an Ordered Stream, and the official reference gives the exact insert behavior and the chunks that run together. Here the constructor and insert calls come as arrays, in order. Our version is about 99% the same as the reported question.

Given n, ids, and values, return the chunk of values an ordered stream outputs after each insert call.

The stream expects exactly n unique pairs, with IDs from 1 through n, and they can arrive in any order. Call i inserts (ids[i], values[i]), and the calls happen in that order.

After each insert, look at the smallest ID whose value has not been output yet. If that ID has arrived, output its value and the values of the IDs right after it, stopping at the first ID that has not arrived. Otherwise output an empty chunk.

Joined together, all chunks list every value in increasing ID order.

Function

orderedStreamChunks(n: int, ids: int[], values: String[]) → String[][]

Examples

Example 1

n = 5ids = [3,1,2,5,4]values = ["ccccc","aaaaa","bbbbb","eeeee","ddddd"]return = [[],["aaaaa"],["bbbbb","ccccc"],[],["ddddd","eeeee"]]

ID 3 arrives before IDs 1 and 2, so it waits. Inserting ID 1 outputs one value, inserting ID 2 outputs IDs 2 and 3, and the same happens later for IDs 4 and 5.

Example 2

n = 1ids = [1]values = ["only"]return = [["only"]]

The only ID arrives in the first call, so that call outputs its value right away.

Example 3

n = 4ids = [2,4,1,3]values = ["b","d","a","c"]return = [[],[],["a","b"],["c","d"]]

The stream waits for ID 1, then outputs IDs 1 and 2. The last call adds ID 3, which comes out with the waiting ID 4.

Constraints

  • 1 <= n <= 1000.
  • ids.length == values.length == n.
  • ids is a permutation of the integers from 1 through n.
  • 1 <= values[i].length <= 100.
  • Each value contains lowercase English letters.

More Bloomberg LP Onsite Interview questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Insert Delete GetRandom O(1)Charta Health · PHONE SCREENCharta Health interview questions
  • Portfolio Tickers with Constant-Time Random PickCitadel · PHONE SCREENCitadel interview questions
  • Randomized String MultisetLinkedIn · PHONE SCREENLinkedIn interview questions
  • Build a Pivot Table with TotalsSigma Computing · PHONE SCREEN
  • Parcel Attribute Store with TTLAirbnb · OAAirbnb interview questions
  • Process Banking OperationsVercel · OA
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions

Interview reports that mention this question

  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad SWE Offer Loops: 14 Experiences (Part 2 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[][] orderedStreamChunks(int n, int[] ids, String[] values) {
        // Write your code here.
    }

}
Checking account…