Bucket Counts
Asked at Datadog
Reported by the problem's creator, not verified
You are given a sorted list of non-negative integers data that you want to summarize as a histogram with num_buckets buckets, each bucket_width wide.
Examples
Example 1
Input: data =
[0,1,2,3,4,5,6,7,8,20], bucket_width =5, num_buckets =4Output:
[5,4,0,1]Explanation: Bucket 0 covers 0 to 4 and holds five values, bucket 1 covers 5 to 9 and holds four, bucket 2 covers 10 to 14 and is empty, and the last bucket takes
20and anything larger.
Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.