P&L Leaderboard Operations
Updated
Problem statement
Process a finite sequence of operations on a trader score leaderboard. Each operation is a string array:
["ADD", traderId, scoreDelta]creates the trader with score0if needed, then adds the positive delta.["TOP", k]emits the sum of thekhighest current trader scores.["RESET", traderId]sets that registered trader's score to0.
Process operations in order and return one long result for every TOP operation, in encounter order.
Function
leaderboardTopSums(operations: String[][]) → long[]Examples
Example 1
operations = [["ADD","1","73"],["ADD","2","56"],["ADD","3","39"],["TOP","2"],["RESET","1"],["ADD","2","45"],["TOP","2"]]return = [129,140]The first top-two sum is 73 + 56. After resetting trader 1 and increasing trader 2 to 101, the second sum is 101 + 39 = 140.
Example 2
operations = [["ADD","10","5"],["ADD","10","7"],["TOP","1"],["RESET","10"],["TOP","1"]]return = [12,0]Repeated ADD operations accumulate. RESET keeps the trader registered with score zero.
Example 3
operations = [["ADD","4","8"],["ADD","2","8"],["ADD","9","3"],["TOP","3"]]return = [19]The only query sums every registered score: 8 + 8 + 3 = 19.
Constraints
1 <= operations.length <= 100000.traderIdis a positive 32-bit integer written in decimal.1 <= scoreDelta <= 1000000.- Every RESET refers to a registered trader.
- Every TOP uses
1 <= k <=the number of registered traders. - At least one TOP operation is present.
- Every emitted sum fits in a signed 64-bit integer.
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
- Read a File from Distributed ChunksHudson River Trading · ONSITE INTERVIEW
- Schedule Invoice Emails and DelinquenciesStripe · ONSITE INTERVIEW
- Pins Violation Log QueriesPinterest · PHONE SCREEN
- Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREEN
- HTTP Request RedirectionAmazon · OA
- Aggregate Paginated Project Run RecordsReplit · OA
- Credit Card Command ProcessorChime · PHONE SCREEN
- Macaron Order with Set DiscountsShopify · OA
- Parcel Attribute Store with TTLAirbnb · OA
- Popular and Instant-Runoff Election WinnersCoursera · PHONE SCREEN
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)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)