Marathon Checkpoint Leaderboard
Updated
Problem statement
Given sensorCount, playerCount, and operations, return the requested leaderboard rows for a marathon.
There are sensorCount checkpoints numbered from 0 to sensorCount - 1. There are playerCount runners numbered from 0 to playerCount - 1.
Every runner starts at checkpoint -1, before all checkpoints. Initially, runners are ranked by increasing runner ID.
Process operations in order:
["PASS", player, sensor]recordsplayerreaching checkpointsensor. This must be the runner's next checkpoint, exactly one greater than their current checkpoint.["TOP", k]requests the firstkrunners. Rank runners by checkpoint, with larger checkpoints first. At the same checkpoint, the runner who arrived earlier comes first.
For each TOP operation, return a row of "player|checkpoint" entries in rank order. Each entry gives the runner ID and their current checkpoint, separated by a vertical bar. Return the rows in the order of the queries.
Function
marathonLeaderboard(sensorCount: int, playerCount: int, operations: String[][]) → String[][]Examples
Example 1
sensorCount = 3playerCount = 4operations = [["PASS","2","0"],["PASS","0","0"],["TOP","4"],["PASS","0","1"],["TOP","3"]]return = [["2|0","0|0","1|-1","3|-1"],["0|1","2|0","1|-1"]]Runner 2 reaches checkpoint 0 before runner 0, so they lead the first query in that order. After runner 0 reaches checkpoint 1, runner 0 leads the next query.
Example 2
sensorCount = 2playerCount = 3operations = [["TOP","2"],["PASS","1","0"],["PASS","2","0"],["PASS","1","1"],["TOP","3"]]return = [["0|-1","1|-1"],["1|1","2|0","0|-1"]]With no passes recorded, the first query lists runners by ID. At the last query, runner 1 leads runner 2, followed by runner 0, who has not passed a checkpoint.
Example 3
sensorCount = 1playerCount = 2operations = [["PASS","1","0"],["PASS","0","0"],["TOP","1"]]return = [["1|0"]]Both runners have reached the finish sensor, and runner 1 arrived first.
Constraints
1 <= sensorCount, playerCount <= 100000.1 <= operations.length <= 100000.- Every operation is
PASSorTOP. - Each
PASSuses a valid runner and that runner's next checkpoint. 1 <= k <= playerCountfor everyTOP.- At least one
TOPoperation is present.
More Bloomberg LP Onsite Interview questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- 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
Similar questions at other companies
- LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
- LRU CacheAMD · ONSITE INTERVIEWAMD interview questions
- Least Recently Used CacheByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- LRU Cache with Hit and Miss CountersLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Least Recently Used CacheGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- LRU CacheIntuit · ONSITE INTERVIEWIntuit interview questions
- LRU CacheOracle · ONSITE INTERVIEWOracle interview questions
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)