Design an Ordered Stream Problem
Design an Ordered Stream Problem — ExecCode Easy DSA Practice
Solve the Design an Ordered Stream problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Design OrderedStream of size n. On each insert(id, value), return the longest contiguous chunk starting from the current pointer. Implement Solution.solve(n, ids, values) and return a list of chunks.
Examples
Input {"n": 5, "ids": [3, 1, 2, 5, 4], "values": ["ccccc", "aaaaa", "bbbbb", "eeeee", "ddddd"]}; Output [[], ['aaaaa'], ['bbbbb', 'ccccc'], [], ['ddddd', 'eeeee']]
Constraints
1 ≤ n ≤ 1000 1 ≤ id ≤ n Each id is unique
Practice Design an Ordered Stream free on ExecCode. Browse DSA problems, topic map, and placement guides.