Tutorialarraymath
Average Score (Rounded Down)
- Memory limit
- 256 MB
- Correctness time limit
- 10000 ms
- Solvers
- 0
Given an array scores of student scores, return their average rounded down to an integer. For an average
of 85.75, return 85.
Examples
| scores | result |
|---|---|
[80, 90, 87, 86] | 85 |
[100] | 100 |
[0, 1] | 0 |
Example 1 — Sum 343, 343 ÷ 4 = 85.75, so 85.
Example 2 — One student: the average is that score.
Example 3 — 0.5 rounded down is 0.
This is a tutorial problem: there are no performance tests, just return the correct value.
Function signature
solution(scores: int[]) → int
Constraints
-
scores.length -
scores[i]
Expected complexity
- Time
- O(N)
- Space
- O(1)
Examples
| scores | Expected |
|---|---|
[80,90,87,86] | 85 |
[100] | 100 |
[0,1] | 0 |
Hint
Hint
Compute the sum, then divide by the count. Integer division sum / n in C, C++, Java and C# already drops the
fraction; in Python use //, because / gives a float.
Time limits per language
| Language | Efficiency time limit | |
|---|---|---|
| C (GCC, gnu17) | 200 ms | estimated |
| C++ (GCC, gnu++23) | 200 ms | derived |
| Python 3.13 | 1000 ms | derived |
| Java 25 | 1000 ms | derived |
| Kotlin 2.4 (JVM) | 1200 ms | estimated |
| C# 14 (.NET 10) | 1200 ms | estimated |
Test groups
| Group | Weight | Tests | Visibility |
|---|---|---|---|
| sample | 0 | 3 | inputs and outputs |
| correctness | 100 | 11 | verdict only |