FastPrepMutable Stock Price Top K
Problems/Mutable Stock Price Top K

Mutable Stock Price Top K

Bloomberg LP logoBloomberg LP● MediumNEW GRADFULLTIMEPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The source gives the update and top-k operations and hints at lazy deletion. It does not say how a replaced price is handled, how ties break, how the output is written, or what the number limits are. Our version is about 90% the same as the reported question.

Special thanks: 🌷 A special thank you to a lovely, amazing fren for sharing a similar interview question, with reported date of October 15, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 🩵

Given operations, return one list of stock symbols for each topK query, in query order.

Maintain each stock's current integer price:

  • ["update", symbol, price] creates the stock if needed and replaces its current price.
  • ["topK", k] returns up to k current stock symbols, from highest price to lowest.

For equal prices, sort symbols in lexicographic order. Compare letters from left to right, putting the earlier letter first at the first difference. If one symbol is a prefix of another, put the shorter symbol first.

If fewer than k stocks exist, return all current stocks.

Function

trackTopStocks(operations: String[][]) → String[][]

Examples

Example 1

operations = [["update","AAPL","150"],["update","MSFT","310"],["update","GOOG","310"],["topK","2"],["update","AAPL","400"],["topK","3"]]return = [["GOOG","MSFT"],["AAPL","GOOG","MSFT"]]

The first query puts GOOG before MSFT because equal prices are resolved by lexicographic order. Updating AAPL to 400 gives it the highest price for the next query.

Example 2

operations = [["update","IBM","100"],["topK","3"],["update","IBM","90"],["topK","1"]]return = [["IBM"],["IBM"]]

The first query returns every current stock because only one exists. Updating IBM replaces its old price rather than adding a second stock entry.

Constraints

  • 1 <= operations.length <= 100000.
  • Every operation is either update or topK.
  • symbol contains between 1 and 10 uppercase English letters.
  • 1 <= price <= 1000000000.
  • 1 <= k <= 100000.

More Bloomberg LP Phone Screen questions

  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
  • Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
  • Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Worst-Performing Ads by CTR in a Campaign TreeUber · PHONE SCREENUber interview questions
  • Design Authentication ManagerOracle · ONSITE INTERVIEWOracle interview questions
  • In-Memory Priority Task SchedulerRippling · PHONE SCREENRippling interview questions
  • Balanced Session ManagerPalantir · PHONE SCREENPalantir interview questions
  • Design a Food Rating SystemApple · PHONE SCREENApple interview questions
  • Key-Value Store on a Block DeviceLambda · PHONE SCREEN
  • Lowest-Bid Auction SystemGoogle · ONSITE INTERVIEWGoogle interview questions
  • Rank-Based Cache with a Data SourceLinkedIn · PHONE SCREENLinkedIn interview questions
  • Thread-Safe Task Storage and Worker DispatchNuro · ONSITE INTERVIEWNuro interview questions
  • Notification Deduplication WindowGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions

Interview reports that mention this question

  • Bloomberg New Grad Question Bank: 161 Questions (Part 1 of 2)
  • Bloomberg New Grad Interviews: 2025 vs 2026 Guide
  • Bloomberg New Grad SWE Offer Loops: 14 Experiences (Part 2 of 5)
  • Bloomberg New Grad SWE Interviews: 98 Experiences (Part 1 of 5)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[][] trackTopStocks(String[][] operations) {
        // Write your code here.
    }

}
Checking account…