Count Score Categories
Problem statement
You are given an integer array scores. Classify every score into exactly one category:
- Failed: the score is less than
50. - Regular pass: the score is from
50through80, inclusive. - Passed with honors: the score is greater than
80.
Return an array containing the three category counts in this order: failed, regular pass, passed with honors.
Function
countScoreCategories(scores: int[]) → int[]Examples
Example 1
scores = [49,50,80,81,100]return = [1,2,2]49 fails, 50 and 80 are regular passes, and 81 and 100 pass with honors.
Example 2
scores = [50,75,80,20,90]return = [1,3,1]Only 20 fails, 50, 75, and 80 are regular passes, and 90 passes with honors.
Example 3
scores = [0,100]return = [1,0,1]0 fails, no score is a regular pass, and 100 passes with honors.
Constraints
1 <= scores.length <= 100.0 <= scores[i] <= 100.
Source note: The image preserves the original Google Coding Exercise example, constraints, and visible counter order; the FastPrep callable name is an execution adapter. Additional original screenshot of the score categories and examples.