PracticeHashing
One-Class Combo Scoreboard
Context
In the arcade game Neon Rally, a player's combo produces one score for each move. The scoreboard analyst wants to know whether every recorded combo score belongs to the same score class, treating repeated scores as one class. This helps identify perfectly consistent scoring runs.
Problem
Given the recorded combo scores in order, determine whether all scores are identical. A score that appears repeatedly still represents only one distinct class. Return true exactly when the complete array contains one distinct score. An empty array contains no score class, so return false for it.
Examples
Example 1
Input:
combo_scores = [100, 100, 100]Output:
TrueExplanation: The array [100, 100, 100] returns true because its final distinct total is 1 and its single-class flag is true. [fact_ids:, ]
Example 2
Input:
combo_scores = [50, 75, 50]Output:
FalseExplanation: The array [50, 75, 50] returns false because its final distinct total is 2 and its single-class flag is false. [fact_ids:, ]
Example 3
Input:
combo_scores = []Output:
FalseExplanation: The empty array returns false because its final distinct total is 0 and its single-class flag is false. [fact_ids:, ]
Constraints
0 <= len(combo_scores) <= 1000000 <= combo_scores[i] <= 1000000 for every i- Types:
combo_scoresis int[]; result is bool
Function signature
def has_one_score_class(combo_scores: list[int]) -> bool
combo_scoreslist[int]- Scores recorded for the player's combo moves.
- returns bool
- Return true if the array contains exactly one distinct score; otherwise return false, including for an empty array.
Adapted from MBPP problem task_760 (CC BY 4.0). Rewritten, extended and verified by Iksha.
Code
Saved