Top Error Types in a Time Window
Updated
Problem statement
Each response row is [timestamp, errorType], where timestamp is a decimal integer string. Count errors in the half-open interval [startTime, endTime).
Return at most k rows formatted as errorType|count. Rank larger counts first and break equal-count ties by lexicographically smaller error type. If fewer than k error types occur in the interval, return all of them.
Function
topErrorTypes(responses: String[][], startTime: long, endTime: long, k: int) → String[]Examples
Example 1
responses = [["100","timeout"],["105","validation"],["108","timeout"],["110","auth"],["112","validation"],["115","timeout"]]startTime = 105endTime = 115k = 2return = ["validation|2","auth|1"]The left boundary is included and the right boundary is excluded. Validation occurs twice; auth and timeout tie once, so auth wins lexicographically.
Constraints
0 <= responses.length <= 200000.0 <= timestamp, startTime, endTime <= 10^18andstartTime < endTime.1 <= k <= 100000.- Error types are non-empty printable ASCII strings containing neither
|nor a newline.
More Notion interview questions
- Nested Todo ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- DAG Downstream NodesONSITE INTERVIEW · Seen Apr 2026
- Mutable Table AggregationsPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2026
- Page Permission InheritancePHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Text Document HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Sliding Window MedianONSITE INTERVIEW · Seen Oct 2025
- Task Row ModificationsONSITE INTERVIEW · Seen Oct 2025
- JSON Block Tree OperationsONSITE INTERVIEW · Seen Jul 2025
- Block Type with the Most ChildrenPHONE SCREEN · Seen Mar 2026
- Country with the Most EventsPHONE SCREEN · Seen Mar 2026
Similar questions at other companies
- Unique Active Pins by Time SegmentPinterest · ONSITE INTERVIEWPinterest interview questions
- Peak Process MemoryNutanix · ONSITE INTERVIEWNutanix interview questions
- Calendar Event System with Pagination and IntersectionLead Bank · ONSITE INTERVIEWLead Bank interview questions
- Highlight and Rank Overlapping CitationsHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
- Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
- Merchant Capacity Interval MergeDoorDash · PHONE SCREENDoorDash interview questions
- Free Time for Every Meeting RoomScale AI · PHONE SCREENScale AI interview questions
- Merge Collinear Point SegmentsApplied Intuition · PHONE SCREENApplied Intuition interview questions
- Worker Management (Promotion Track), Part 4: Full-Shift Double PayAirbnb · OAAirbnb interview questions
- Lab and Consultation Appointment MatchingAssort Health · PHONE SCREENAssort Health interview questions