Tutorialimplementation
Grade from Score
- Memory limit
- 256 MB
- Correctness time limit
- 10000 ms
- Solvers
- 0
Given a test score, return the grade as a string according to this table:
| Score | Grade |
|---|---|
| 90 or more | "A" |
| 80 – 89 | "B" |
| 70 – 79 | "C" |
| 60 – 69 | "D" |
| below 60 | "F" |
Examples
| score | result |
|---|---|
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
-
score, an integer.
Expected complexity
- Time
- O(1)
- Space
- O(N)
Examples
| score | Expected |
|---|---|
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
| 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 | 12 | verdict only |