FastPrepPeak Concurrent Calls by UTC Day
Problems/Peak Concurrent Calls by UTC Day

Peak Concurrent Calls by UTC Day

HubSpot logoHubSpot● HardFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a HubSpot online assessment. The original report allowed any peak timestamp and did not say how to order the result. This version uses the earliest peak timestamp and a fixed ordering. Our version is about 94% the same as the reported question.

You are given records for completed phone calls. Record i belongs to customer customerIds[i], has unique identifier callIds[i], and is active during the half-open interval [startTimestamps[i], endTimestamps[i]). Timestamps are Unix milliseconds in UTC.

For every customer and every UTC date on which at least one of that customer's calls is active, find the maximum number of concurrent calls during that date.

Peak selection

  • Choose the earliest millisecond in the date at which the maximum concurrency is active.
  • A call ending at a timestamp is not active at that timestamp. A call starting at that timestamp is active.
  • Include exactly the call IDs active at the chosen timestamp, sorted lexicographically.

Return format

Return one string per customer-date pair in this exact format:

customerId|YYYY-MM-DD|maxConcurrentCalls|timestamp|callId1,callId2,...

Sort the returned strings by numeric customer ID, then by date. A call spanning midnight contributes independently to each UTC date it intersects.

Function

peakConcurrentCalls(customerIds: int[], callIds: String[], startTimestamps: long[], endTimestamps: long[]) → String[]

Examples

Example 1

customerIds = [1,1,1,2]callIds = ["A","B","C","X"]startTimestamps = [0,10,20,86399990]endTimestamps = [30,20,86400010,86400020]return = ["1|1970-01-01|2|10|A,B","1|1970-01-02|1|86400000|C","2|1970-01-01|1|86399990|X","2|1970-01-02|1|86400000|X"]

Customer 1 first reaches two active calls at timestamp 10. Call C continues into the next UTC date. Customer 2's call also crosses midnight, so both customers have a record for 1970-01-02.

Example 2

customerIds = [7,7]callIds = ["left","right"]startTimestamps = [100,200]endTimestamps = [200,300]return = ["7|1970-01-01|1|100|left"]

The first call ends exactly when the second begins, so the half-open intervals never overlap. The earliest timestamp with the maximum concurrency of 1 is 100.

Example 3

customerIds = [4,4]callIds = ["before","after"]startTimestamps = [86399999,86400000]endTimestamps = [86400000,86400001]return = ["4|1970-01-01|1|86399999|before","4|1970-01-02|1|86400000|after"]

The call ending at midnight belongs only to 1970-01-01. The call starting at midnight belongs to 1970-01-02.

Constraints

  • 1 <= customerIds.length <= 100000
  • All four input arrays have the same length.
  • 1 <= customerIds[i] <= 10^9
  • Every callIds[i] is unique, nonempty, and contains only ASCII letters, digits, underscores, or hyphens.
  • 0 <= startTimestamps[i] < endTimestamps[i] <= 4102444800000
  • Across all calls, the total number of intersected UTC dates is at most 200000.

Similar questions at other companies

  • Worker Management (Promotion Track), Part 4: Full-Shift Double PayAirbnb · OAAirbnb interview questions
  • Worker Management, Part 4: Double-Paid IntervalsAnthropic · OAAnthropic interview questions
  • Highlight and Rank Overlapping CitationsHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
  • Merge Collinear Point SegmentsApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Worker Management with Promotions and Double-Paid TimeInstacart · ONSITE INTERVIEWInstacart interview questions
  • Lab and Consultation Appointment MatchingAssort Health · PHONE SCREENAssort Health interview questions
  • Unique Active Pins by Time SegmentPinterest · ONSITE INTERVIEWPinterest interview questions
  • Peak Process MemoryNutanix · ONSITE INTERVIEWNutanix interview questions
  • Merchant Capacity Interval MergeDoorDash · PHONE SCREENDoorDash interview questions
  • Calendar Event System with Pagination and IntersectionLead Bank · ONSITE INTERVIEWLead Bank interview questions
See HubSpot hiring insights
Saved
class Solution {
    public String[] peakConcurrentCalls(int[] customerIds, String[] callIds, long[] startTimestamps, long[] endTimestamps) {
        // write your code here
    }
}
Checking account…