Implement min, mean, median robustly
Company: Thumbtack
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
Quick Answer: This question evaluates implementation skills in basic descriptive statistics (min, mean, median), numerical stability in online aggregation methods, robust handling of edge cases like None/NaN and extreme numeric ranges, and algorithmic complexity reasoning in the Coding & Algorithms domain for a Data Scientist role.
Minimum of a Numeric List
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([3,1,2],)
Expected Output: 1
Explanation: Minimum.
Input: ([],)
Expected Output: None
Explanation: Empty list.
Hints
- Use deterministic tie-breaking for prompts with multiple valid outputs.
- For design-style APIs, simulate operations with explicit inputs.
Numerically Stable Mean
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([1,2,3],)
Expected Output: 2.0
Explanation: Mean 2.
Input: ([],)
Expected Output: None
Explanation: Empty list.
Input: ([1e16,1,-1e16],)
Expected Output: 0.0
Explanation: Large cancellation case.
Hints
- Use deterministic tie-breaking for prompts with multiple valid outputs.
- For design-style APIs, simulate operations with explicit inputs.
Median of a Numeric List
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([3,1,2],)
Expected Output: 2
Explanation: Odd length.
Input: ([4,1,2,3],)
Expected Output: 2.5
Explanation: Even length.
Input: ([],)
Expected Output: None
Explanation: Empty list.
Hints
- Use deterministic tie-breaking for prompts with multiple valid outputs.
- For design-style APIs, simulate operations with explicit inputs.