Explanation

476.Calculate Letter Grade from a Percentage Score

Easy
Given an integer score between 0 and 100, return the letter grade it earns: "A" for 90 and above, "B" for 80-89, "C" for 70-79, "D" for 60-69, and "F" below 60. The if-else ladderIf-Else LadderA chain of else-if conditions, checked top to bottom, where only the first one that matches actually runs. version is the natural way to express "check the highest threshold first, then the next, then the next." The bucket lookupBucket LookupDividing by a fixed width (10, for 10-point grade bands) to collapse a whole range of scores onto one representative number, then branching on that number instead of the original value. version first reduces the input to a single digit using integer division, then branches on that much smaller space — the same idea used for digit extraction and radix-based problems elsewhere in programming.

Example 1:

Input: score = 95

Output: "A"

Example 2:

Input: score = 82

Output: "B"

Example 3:

Input: score = 55

Output: "F"

+ 8 hidden test cases run on Submit.

Constraints:

  • ●0 ≤ score ≤ 100

score =

95