Problem 204053 · easy · Phase 02 Linear Data Structures

Judges' Score

arrays · running-statistics · iteration

In a diving contest each judge gives a score. The final score drops exactly one highest and exactly one lowest score and averages the rest. Given scores (at least three), return that average rounded to 2 decimal places with round(x, 2).

Examples

Input:  scores = [9, 7, 10, 8, 6]
Output: 8.0
Explanation: Drop 10 and 6; (9 + 7 + 8) / 3 = 8.0.

Input:  scores = [5, 5, 5]
Output: 5.0
Explanation: One 5 is dropped as the highest, one as the lowest, one remains.

Constraints

  • 3 <= len(scores) <= 10**5
  • 0 <= scores[i] <= 100
  • Target: O(n) time, O(1) extra space (no sorting).

Goals

  • Track sum, minimum and maximum in a single pass
  • Exclude exactly one extreme at each end even when values repeat
Starting Python…