A school nurse measured pupils' heights in millimetres. Almost every height is different, so asking which height is most common tells you nothing. Instead she groups the heights into bands of width millimetres that start at multiples of width: with width = 50 the bands are 0-49, 50-99, ..., 1350-1399, 1400-1449, and so on.
Write busiest_bands(heights, width) that returns the labels of the band or bands holding the most pupils, from the lowest band to the highest. A label is the band's first and last whole millimetre joined by a hyphen, like "1400-1449". An empty list of heights gives [].
Examples
Input: heights = [1412, 1388, 1455, 1431, 1402, 1379, 1447, 1466, 1391], width = 50
Output: ["1400-1449"]
Explanation: 1350-1399 holds 3 pupils, 1400-1449 holds 4, 1450-1499 holds 2.
Input: heights = [1412, 1388, 1455, 1431, 1379, 1466], width = 50
Output: ["1350-1399", "1400-1449", "1450-1499"]
Explanation: every band holds 2 pupils, so all three are tied.
Input: heights = [995, 1005, 1009], width = 10
Output: ["1000-1009"]
Constraints
0 <= len(heights) <= 10**5, every height a whole number with0 <= height <= 25001 <= width <= 1000
Goals
- See why the mode of precise measurements is meaningless
- Group values into bins and find the most common bin
- Label bins clearly and report every tied bin