FastPrepCount Events in Rolling Minute Windows
Problems/Count Events in Rolling Minute Windows

Count Events in Rolling Minute Windows

Meta logoMeta● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta phone screen. We keep minute buckets, a rolling hour, expiry, and the time example from the report. We chose the order of timestamps, how the window edges work, and the input limits. Our version is about 85% the same as the reported question.

Implement a counter service that records bump() events by minute and answers query() with the number of events in a rolling 60-minute window, accurate to one minute. Stop counting a minute once it falls outside the window. Do not use a stack; use constant-size counter state for the fixed 60-minute window.

Rules

You receive two nondecreasing arrays of integer minute indices: eventMinutes contains one entry for every bump, and queryMinutes contains the query times. Process events and queries together in time order. Before a query at minute t, record every event with timestamp at most t. Do not record events whose timestamps are later than the query.

For each query, return the number of events with minute indices in the inclusive interval [t - 59, t], in query order. Repeated events at the same minute count separately, and all events at a query minute are recorded before that query. Repeated queries do not change the count. Return an empty array when there are no queries.

For example, events at 1:01, 1:02, and 1:15 correspond to minute indices 61, 62, and 75. A query at 1:10 (70) returns 2; the future 1:15 event is excluded. At 2:05 (125), the first two events have expired and the count is 1.

Function

countMinuteEvents(eventMinutes: int[], queryMinutes: int[]) → int[]

Examples

Example 1

eventMinutes = [61,62,75]queryMinutes = [70,125]return = [2,1]

At minute 70, only events 61 and 62 have occurred. At minute 125, the window is [66,125], so only event 75 remains.

Example 2

eventMinutes = [0,0,59,60]queryMinutes = [0,59,60]return = [2,3,2]

Both events at minute 0 are visible to the first query. At minute 60, minute 0 is outside [1,60], while events 59 and 60 remain.

Example 3

eventMinutes = []queryMinutes = [0,1000000000]return = [0,0]

No events are recorded, so both queries return zero.

Constraints

  • For this exercise, assume 0 <= eventMinutes.length, queryMinutes.length <= 100000.
  • For this exercise, assume every minute index is in [0, 10^9] and each array is nondecreasing.
  • For this exercise, assume equal-minute events precede queries and the window contains the current minute and the previous 59 minute buckets.
  • The fixed 60-minute service state must use O(1) space, excluding the supplied arrays and returned results. Each bump and query must use O(1) time for this fixed window.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Customer Bootstrap APIDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
  • Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • Implement a FIFO QueueByteDance · PHONE SCREENByteDance interview questions
  • Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
  • Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Music Player Operation SequenceAtlassian · PHONE SCREENAtlassian interview questions
  • Resizable Array-Backed Integer SetThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Stack with Constant-Time Middle QueriesAmazon · PHONE SCREEN

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public int[] countMinuteEvents(int[] eventMinutes, int[] queryMinutes) {
        // Write your code here.
    }
}
Checking account…