Back to problems

Top-K Frequent Tickers (Stock Leaderboard)

Object-Oriented Programming · Bloomberg · Hard

Requirements Design a class with these operations: insert(symbol) — add one occurrence of symbol to the current state. delete(symbol) — remove one occurrence of symbol. If the symbol is absent, the behavior is undefined or may be a no-op; confirm the intended rule with the interviewer. topK(int k) — return the k symbols whose current occurrence counts are greatest. The interviewer may allow ties to be resolved by symbol order or by insertion order, so clarify the…

Checking your access…