Software Engineer • Senior-Level
Software Engineer • Senior-Level
High QualityPrep Other Coding Questions Asked by Datadog
Continue with targeted prep from Datadog's coding question bank.
Interview Summary
The main detail was handling the final bucket differently from the others: instead of having a fixed upper bound, it needed to capture all remaining latencies, including values beyond the normal bucket ranges. The problem itself was relatively straightforward and focused on array processing and boundary conditions.
Interview Details
Coding: Latency Bucket Counter
Given a sorted array of positive integers latencies, where each value represents a request's latency in milliseconds, group the values into a predefined number of fixed-width buckets. The input contains three parameters:
latencies: An array of positive integers sorted in ascending order.numOfBuckets: The total number of buckets to create.bucketWidth: The width of each bucket in milliseconds.
Bucket Definition
Buckets are indexed from 0 to numOfBuckets - 1. For each bucket i, except the last one, the latency range is: [i * bucketWidth, (i + 1) * bucketWidth - 1]. Both endpoints are inclusive. The last bucket is an overflow bucket. It includes every latency greater than or equal to its lower bound, without an upper limit. For example, if bucketWidth = 25 and numOfBuckets = 4, the buckets are:
- Bucket 0:
[0, 24] - Bucket
Unlock Full Details
Create a free account to unlock this interview experience report.