Funcia
Tutorialimplementation

Grade from Score

Memory limit
256 MB
Correctness time limit
10000 ms
Solvers
0
0

Given a test score, return the grade as a string according to this table:

ScoreGrade
90 or more"A"
80 – 89"B"
70 – 79"C"
60 – 69"D"
below 60"F"

Examples

scoreresult
95"A"
80"B"
59"F"

Example 1 — 95 is at least 90: A.

Example 2 — 80 is in 80–89: B.

Example 3 — Below 60: F.

This is a tutorial problem: there are no performance tests, just return the correct value.

Function signature

solution(score: int) → string

Constraints

  • 0≤0 \le score ≤100\le 100, an integer.

Expected complexity

Time
O(1)
Space
O(N)

Examples

scoreExpected
95"A"
80"B"
59"F"

Hint

Hint

Check the conditions from the highest grade down with if / else if; then each branch only needs a lower bound. Make sure the boundary scores 90, 80, 70 and 60 land in the right grade.

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
correctness10012verdict only
Loading editor…
Log in to run or submit code.

No result yet. Run or submit your code.