BasicsPercentilesGoogleMetaJane Street
Problem
Implement percentile_rank(data, score) returning the percentage (0.0 to 100.0) of observations in data that are less than or equal to score: 100×ncount(x≤score).
Why It Matters: Percentile ranks power SLA latency reporting, standardized test scoring, and rank-based feature transforms.
Function Signature
def percentile_rank(data: list[float], score: float) -> float:
Sample Input & Output
Example 1: Mid-Range Score
Input:
data = [10, 20, 30, 40, 50], score = 30
Expected Output:
60.0
Explanation: 3 of 5 values (10, 20, 30) are <= 30, giving 60.0%.
Example 2: Below Minimum & Above Maximum
Input:
data = [10, 20, 30], score = 5
Expected Output:
0.0
Explanation: 0 values are <= 5 → 0.0% (similarly score = 99 would return 100.0%).
Constraints & Edge Cases
- Return percentile rank in
[0.0, 100.0]. - Use inclusive comparison
v <= score. - Return a float percentage in
[0.0, 100.0].
Constraints & Evaluation Criteria
- Return percentile rank in `[0.0, 100.0]`.
Hints
Python 3⌘/Ctrl+Enter to Run · ⌘/Ctrl+Shift+Enter to Submit
Loading Code Editor...
+1 Hidden Submit Case
Input / Scenario
[10, 20, 30, 40, 50], score=40
Expected Output / Criteria
80.0