Funcia
Tutorialarraymath

Average Score (Rounded Down)

Memory limit
256 MB
Correctness time limit
10000 ms
Solvers
0
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

scoresresult
[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

  • 1≤1 \le scores.length ≤1,000\le 1{,}000
  • 0≤0 \le scores[i] ≤100\le 100

Expected complexity

Time
O(N)
Space
O(1)

Examples

scoresExpected
[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

LanguageEfficiency time limit
C (GCC, gnu17)200 msestimated
C++ (GCC, gnu++23)200 msderived
Python 3.131000 msderived
Java 251000 msderived
Kotlin 2.4 (JVM)1200 msestimated
C# 14 (.NET 10)1200 msestimated

Test groups

GroupWeightTestsVisibility
sample03inputs and outputs
correctness10011verdict only
Loading editor…
Log in to run or submit code.

No result yet. Run or submit your code.