FastPrepThree Hits in the Last Three Seconds
Problems/Three Hits in the Last Three Seconds

Three Hits in the Last Three Seconds

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A junior-level candidate's report on a first online interview round at Bloomberg lists this task as a twist on the well-known hit counter problem: instead of returning how many hits came in recently, decide whether at least three hits landed during the previous three seconds. The author calls it a small rate limiter. The round also held a second medium question, which is a separate task. The report gives no example, input format or limits.

Our choices: the hits and the questions come as two lists, operations and timestamps, in one function. Every hit counts, a check changes nothing, and several hits can share one second. The last three seconds at time t are the seconds t - 2, t - 1 and t. A run has up to 10,000 operations, with times from 0 to 1,000,000,000 that never go backwards.

The judged task matches the report at about 85%.

A website counts hits and wants to notice bursts. For example, hits at seconds 1, 2 and 3 are 3 hits in the last 3 seconds at second 3.

You get two arrays of the same length, operations and timestamps. Run them from first to last on a monitor that starts with no hits. operations[i] happens at second timestamps[i].

  • "hit": one hit happens at this second. Several hits can happen in the same second, and each one counts.
  • "check": answer whether the last 3 seconds hold at least 3 hits. At second t, the last 3 seconds are the seconds t - 2, t - 1 and t. Count every hit so far that happened in those seconds, including hits at second t that came earlier in the arrays. A check changes nothing.

Return a list with one boolean for each "check", in the order they run: true when the count is at least 3 and false otherwise. If there is no "check", return an empty list.

Function

runHitMonitor(operations: String[], timestamps: int[]) → boolean[]

Examples

Example 1

operations = ["hit","hit","check","hit","check","check"]timestamps = [1,2,2,3,3,6]return = [false,true,false]

At time 2 the window is seconds 0 to 2 and holds the hits at times 1 and 2: 2 hits, so false. At time 3 the window is seconds 1 to 3 and holds the hits at 1, 2 and 3: 3 hits, so true. At time 6 the window is seconds 4 to 6 and holds no hits, so false. The answer is [false,true,false].

Example 2

operations = ["hit","hit","hit","check","check","check"]timestamps = [5,5,5,5,7,8]return = [true,true,false]

Three hits in the same second all count, so the check at time 5 is true. At time 7 the window is seconds 5 to 7, which still holds the three hits at time 5, so it is true. At time 8 the window is seconds 6 to 8, which holds none, so it is false. The answer is [true,true,false].

Example 3

operations = ["hit","hit","check","hit","hit","hit","check"]timestamps = [10,11,11,12,13,13,13]return = [false,true]

At time 11 the window holds the hits at 10 and 11: 2 hits, so false. Later hits keep counting. At time 13 the window is seconds 11 to 13 and holds the hits at 11, 12, 13 and 13: 4 hits, which is at least 3, so true. The answer is [false,true].

Constraints

  • 1 <= operations.length <= 10000
  • timestamps.length == operations.length
  • Each operations[i] is "hit" or "check".
  • 0 <= timestamps[i] <= 1000000000
  • timestamps is nondecreasing: an operation never happens earlier than the one before it. Several operations can share the same second.

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
  • Mutable Stock Price Top KPHONE 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

Similar questions at other companies

  • Rolling Hit CounterDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
  • Per-Client API Rate LimiterDocker · PHONE SCREEN
  • Per-Client Sliding-Window Rate LimiterCVS Health · PHONE SCREEN
  • Rolling CSAT TrackerDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Sliding-Window Rate LimiterUber · PHONE SCREENUber interview questions
  • Recent Advertisement Click CountsAmazon · PHONE SCREEN
  • Delayed Streaming Duplicate SuppressionGoogle · PHONE SCREENGoogle interview questions
  • Completions API Rate LimiterCursor · PHONE SCREENCursor interview questions
  • Sliding-Window Rate LimiterStripe · PHONE SCREEN · ONSITE INTERVIEWStripe interview questions
  • Moving Average of a Data StreamSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions

Interview reports that mention this question

  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
  • Bloomberg New Grad Interviews: 2025 vs 2026 Guide

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)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public boolean[] runHitMonitor(String[] operations, int[] timestamps) {
        // Write your code here.
    }
}
Checking account…