FastPrepTrade Volume Leaderboard
Problems/Trade Volume Leaderboard

Trade Volume Leaderboard

Bloomberg LP logoBloomberg LP● HardNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asks for execute_trade(company, volume) and print_topk_company(top_n). It needs total volume for each company, wants top-k queries to be very fast, and asks how the design changes when k is below 5 and when trade updates must also be fast. Its sample labels a call top_n=2 but visibly lists three ranked companies. We settle that by following the function name and returning exactly k companies. Ties go to the company that comes first alphabetically.

Process a sequence of company trade-volume operations. The leaderboard starts empty.

  • ["TRADE", company, volume] adds the positive integer volume to that company's cumulative traded volume.
  • ["TOP", k] requests the current top k companies.

For every TOP operation, return one row whose entries have the form "company|cumulativeVolume", ranked by decreasing cumulative volume and then lexicographically by company when volumes tie. Return the query rows in encounter order.

Function

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

Examples

Example 1

operations = [["TRADE","MSFT","900"],["TRADE","APPL","300"],["TRADE","GOOG","1000"],["TRADE","APPL","400"],["TRADE","META","200"],["TRADE","BA","500"],["TOP","2"]]return = [["GOOG|1000","MSFT|900"]]

APPL accumulates to 700, but GOOG and MSFT have the two largest totals.

Example 2

operations = [["TRADE","A","5"],["TRADE","B","7"],["TOP","2"],["TRADE","A","4"],["TOP","1"]]return = [["B|7","A|5"],["A|9"]]

The second trade raises A's cumulative volume from 5 to 9.

Example 3

operations = [["TRADE","ZZ","10"],["TRADE","AA","10"],["TRADE","MM","10"],["TOP","3"]]return = [["AA|10","MM|10","ZZ|10"]]

Equal totals are ordered lexicographically by company.

Constraints

  • 1 <= operations.length <= 100000.
  • Every operation is TRADE or TOP.
  • company contains between 1 and 10 uppercase English letters.
  • 1 <= volume <= 10^9.
  • For every query, 1 <= k <= the number of companies seen so far.
  • Each cumulative volume fits in a signed 64-bit integer.
  • At least one TOP operation is present.

More Bloomberg LP Onsite Interview questions

  • Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • 15-Minute Chat Session TrackerOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Top K Upvoted Songs by ArtistAmazon · ONSITE INTERVIEW
  • LRU Cache with TTLAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Dynamic Median with Additions and DeletionsByteDance · ONSITE INTERVIEWByteDance interview questions
  • Capacity-Limited Timed CacheNetflix · PHONE SCREENNetflix interview questions
  • Tiered Expiring Item StoreHudson River Trading · PHONE SCREEN · ONSITE INTERVIEWHudson River Trading interview questions
  • Thread-Safe LRU Cache with TTLLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Top K Frequent Elements After Each Stream UpdateSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Tiered Expiring Item StoreAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Multi-Level Inventory Storage SystemOptiver · OA · PHONE SCREENOptiver interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)

Bloomberg LP interview experiences

  • Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
  • Bloomberg SWE Intern Interview Questions: 68 Questions
  • Bloomberg Interview Questions, Level Not Reported: 65 Questions
  • Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
  • Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public String[][] tradeVolumeLeaderboard(String[][] operations) {
        // Write your code here.
    }

}
Checking account…