Bucket Counts
Put each whole number of nums (all 0 or more) into a bucket numbered x // width, so with width 10 the numbers 0 to 9 go in bucket 0, 10 to 19 in bucket 1, and so on. Return a list with the count of each bucket from bucket 0 up to the highest bucket in use (buckets in between may have count 0).
Example 1
nums [3,12,7,25,19]
width 10
returns [2,2,1]
Bucket 0: 3 and 7. Bucket 1: 12 and 19. Bucket 2: 25.
Constraints
1 <= len(nums) <= 1001 <= width <= 50- All numbers are whole and 0 or more
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Busiest ColumnEasy
- Change Between RowsEasy
- Close EnoughEasy
- Closest to OriginEasy
- Closest to TargetEasy
- Column MaximumsEasy
- Column WinnersEasy
- Compound GrowthEasy