FastPrepFive-Minute Hit Counter
Problems/Five-Minute Hit Counter

Five-Minute Hit Counter

Sentry logoSentry● MediumNEW GRADPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Firsthand Sentry interview reports ask candidates to record function calls during the trailing five minutes and discard older timestamps. This chronological operation sequence exposes the reported hit and query behavior directly.

Process chronological hit and getHits operations. A query returns the number of hits in the inclusive interval from timestamp - 299 through timestamp. Return "null" for a hit and the decimal count for a query.

Function

runHitCounter(operations: String[], timestamps: int[]) → String[]

Examples

Example 1

operations = ["hit","hit","hit","getHits","hit","getHits"]timestamps = [1,2,3,4,300,301]return = ["null","null","null","3","null","3"]

At time 301, the hit at time 1 has expired but the other three remain.

Constraints

  • Operation and timestamp arrays have equal non-zero length.
  • Timestamps are positive and non-decreasing.
  • There are at most 100000 operations.

More Sentry interview questions

  • Word Wrap with Even JustificationOA · PHONE SCREEN · Seen Dec 2025
  • Find All Word Occurrences in TextPHONE SCREEN · Seen Mar 2023
  • Wildcard Bad-Word FilterOA · Seen Aug 2022
  • Minimum Meeting RoomsPHONE SCREEN · Seen Feb 2022

Similar questions at other companies

  • Rolling Hit CounterDatabricks · PHONE SCREEN · ONSITE INTERVIEWDatabricks interview questions
  • Design Hit CounterCharta Health · PHONE SCREENCharta Health interview questions
  • Per-Client API Rate LimiterDocker · PHONE SCREEN
  • Round-Robin Iterator over IteratorsBridge · ONSITE INTERVIEWBridge interview questions
  • Sliding Window Rate LimiterLotusFlare · ONSITE INTERVIEW
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • VIP and Regular Service SchedulerIntuit · PHONE SCREENIntuit interview questions
  • Per-Client Sliding-Window Rate LimiterCVS Health · PHONE SCREEN
  • Rolling CSAT TrackerDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Design Hit CounterNutanix · ONSITE INTERVIEWNutanix interview questions

Interview reports that mention this question

  • Sentry SWE New Grad First Technical Interview: 4 Experiences
  • Sentry Software Engineer Interview Questions: 18 Experiences
  • Sentry SWE New Grad OA and Technical Screen: 12 Experiences

Sentry interview experiences

  • Sentry Experienced First Technical Interview: 8 Experiences
  • Sentry SWE Intern First Technical Interview: 10 Experiences
  • Sentry Experienced Engineer Interviews: 14 Experiences
All Sentry interview questionsSee Sentry hiring insights
Saved
class Solution {
    public String[] runHitCounter(String[] operations, int[] timestamps) {
      // Write your code here.
    }

}
Checking account…