Answer: ADOBE MTS | Heap-Based Interval Processing and Offline Query Optimization | On
Answer · Posted Jun 2026
Approach A brute-force approach would check every interval for every query: O(N × Q) which is too slow. Instead, we use: Sorting Offline Query Processing Min Heap (Priority Queue) Strategy Step 1 Sort intervals by starting point. Step 2 Store queries along with their original indices and sort them. (index, query) Step 3 For each query: Add all intervals whose: start <= query into a Min Heap. Heap stores: (intervalSize, intervalEnd) Step 4 Remove intervals that no longer contain the ...
The full answer & interview discussion are available to premium members.
Log in Create a free account