You are building a core component of a real-time analytics system that monitors the profitability of experiences (games, features, events) on a large online platform. The component must efficiently track the current highest-earning experience as profit changes over time.
You will receive a stream of operations of two types:
Update — adjust the profit of an experience by some delta (can be positive or negative).
Query — return the name of the experience with the highest total earnings at that moment.
The stream is given as three equal-length arrays:
operations[i] — either "U" (update) or "Q" (query).
experiences[i] — the name of the experience involved in operation i. For a query operation, this value is unused and may be the empty string.
deltas[i] — for an update, the signed change to that experience's profit. For a query, the value is unused.
Return an array containing the result of every Query operation, in the order the queries appear.
Tie-break. If two or more experiences are tied for the highest total earnings at the time of a query, return the lexicographically smallest name among them.
If a query is issued before any Update has occurred, return the empty string for that query.
This was reported from a Roblox onsite (March 2026). The interviewer explicitly asked for a heap-based solution — a single hash map gives O(1) updates but O(N) queries, and the heap is what prioritizes query time.
After the first two updates: adopt-me = 100, blox-fruits = 200. First query returns "blox-fruits". After the third update: adopt-me = 250, blox-fruits = 200. Second query returns "adopt-me".
Both experiences have profit 50. Tie-break by lexicographic order returns "alpha".
After deltas, x has profit 70, then 70, then -30. x is always the only experience, so it wins every query — even with negative profit.