All problems

Trivia Score Bands

Easy · hash map

A trivia night splits the players into score bands of ten points: one band is the scores 0 to 9, the next is 10 to 19, then 20 to 29, and so on. You are given the list scores, one score per player, in the order the players finished.

Group the scores by band and return a list of groups, where each group is a list of the scores that fall in one band.

Examples

Example 1

Input: scores = [42, 7, 45, 13, 9, 18]

Output: [[42, 45], [7, 9], [13, 18]]

42 and 45 are in the 40s. 7 and 9 are in the 0 to 9 band. 13 and 18 are in the teens. The 40s band appeared first, so it is the first group.

Example 2

Input: scores = [30, 10, 30]

Output: [[30, 30], [10]]

Example 3

Input: scores = [5]

Output: [[5]]

Constraints