Earliest One-Hour Badge Alert Times
Updated
Problem statement
Each row of records is [employee,time] and records an employee badging into a secured room. The rows are unordered. Each time is a valid 24-hour compact HHMM string of one to four digits, such as 800 or 2250. All events occur during a single day.
Find every employee with at least three badge events in an inclusive one-hour period. If several such periods exist, select the earliest one for that employee. Return every badge time in that selected hour, rather than only the first three.
For this exercise, assume each candidate hour starts at one of the employee's badge events and spans the next 60 minutes, including both endpoints. An hour does not wrap across midnight.
For this exercise, assume compact times are left-padded to four digits when interpreted, so 5 means 00:05 and 109 means 01:09. Leading zeroes are allowed.
Return one row [employee,time1,time2,...] per qualifying employee. For this exercise, assume employee rows are sorted lexicographically; times are sorted chronologically while retaining their original text, and equal times preserve input order. Each record counts separately, even when the employee and time are repeated. An empty input returns an empty result.
Function
badgeAlerts(records: String[][]) → String[][]Examples
Example 1
records = [["Paul","1355"],["Jennifer","1910"],["John","835"],["John","830"],["Paul","1315"],["John","1615"],["John","1640"],["Paul","1405"],["John","855"],["John","930"],["John","915"],["John","730"],["John","940"],["Jennifer","1335"],["Jennifer","730"],["John","1630"],["Jennifer","5"]]return = [["John","830","835","855","915","930"],["Paul","1315","1355","1405"]]Each employee's earliest qualifying window is shown, with employee rows sorted. Every badge time within the selected hour is included.
Example 2
records = [["Amy","1000"],["Amy","1030"],["Amy","1100"],["Amy","1101"],["Bob","10"],["Bob","111"],["Bob","212"]]return = [["Amy","1000","1030","1100"]]Amy's hour begins at 10:00 and includes the access exactly 60 minutes later. The next access is outside that hour; Bob has no qualifying hour.
Constraints
- For this exercise, assume there are at most
1000events. - Employee identifiers are nonempty case-sensitive alphanumeric strings of at most
30characters. - Every time represents an hour from
0through23and a minute from0through59. - Each input row has exactly two strings.
More Indeed Phone Screen questions
- Insert into an Unrolled Linked ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Course Completion OrderPHONE SCREEN · Seen May 2025
- Recipes You Can PreparePHONE SCREEN · Seen May 2025
- Rotting Orange PropagationPHONE SCREEN · Seen May 2025
- Courses Shared by Every Student PairPHONE SCREEN · Seen Aug 2022
- First and Last Access Time per UserPHONE SCREEN · Seen Jul 2022
- Most Accessed Resource in Five MinutesPHONE SCREEN · Seen Jul 2022
- Resource Transition GraphPHONE SCREEN · Seen Jul 2022
- Count Disappearing Connected TilesPHONE SCREEN · Seen Jul 2022
- First Dictionary Word from Note LettersPHONE SCREEN · Seen Jul 2022
Similar questions at other companies
- Reconcile Unmatched Trades with Timestamp ToleranceCitadel · PHONE SCREENCitadel interview questions
- Disjoint Target-Sum TripletsAmerican Express · PHONE SCREENAmerican Express interview questions
- Earliest One-Hour Badge Alert TimesAtlassian · PHONE SCREENAtlassian interview questions
- Earliest One-Hour Badge Alert TimesRobinhood · PHONE SCREENRobinhood interview questions
- Top K Best-Selling Products in the Last N DaysAmazon · ONSITE INTERVIEW
- All Distinct Palindromic SubstringsDoorDash · ONSITE INTERVIEWDoorDash interview questions
- Efficient TeamsExpedia · OAExpedia interview questions
- Count Cross-Array Target-Sum PairsVisa · OAVisa interview questions
- Two SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Valid Triangle NumberBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions