Algorithm · ByteDance · Hard
Requirements Work through the following stack and streaming-data tasks, arranged from simpler to more advanced: MinStack: build a regular stack offering push, pop, and top, while allowing getMin to run in O(1). MaxStack: provide the analogous stack behavior, except getMax must also be O(1); common extensions additionally ask for peekMax and popMax. Streaming Median: numbers arrive individually. Once each number is added, report the median of all values seen so far in O(log…
Checking your access…