7 kyu

Histogram data

125 of 804Jenik

Description:

You will be given an array of non-negative integers and positive integer bin width.

Your task is to create the Histogram method that will return histogram data corresponding to the input array. The histogram data is an array that stores under index i the count of numbers that belong to bin i. The first bin always starts with zero.

On empty input you should return empty output.

Examples:

  • For input data [1, 1, 0, 1, 3, 2, 6] and binWidth=1 the result will be [1, 3, 1, 1, 0, 0, 1] as the data contains single element "0", 3 elements "1" etc.
  • For the same data and binWidth=2 the result will be [4, 2, 0, 1]
  • For input data [7] and binWidth=1 the result will be [0, 0, 0, 0, 0, 0, 0, 1]
Fundamentals
Algorithms
Arrays
Data Science

Similar Kata:

Stats:

CreatedApr 6, 2016
PublishedApr 6, 2016
Warriors Trained2258
Total Skips64
Total Code Submissions3864
Total Times Completed804
C# Completions125
Python Completions693
Total Stars35
% of votes with a positive feedback rating90% of 126
Total "Very Satisfied" Votes107
Total "Somewhat Satisfied" Votes12
Total "Not Satisfied" Votes7
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Jenik Avatar
  • KataSideKick Avatar
  • FArekkusu Avatar
  • hobovsky Avatar
Ad