Quick Overview

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.

Implement min, mean, median robustly

Company: Thumbtack

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Implement three functions in Python without using numpy/pandas: (1) my_min(nums) returning the minimum in O(n) time and O(1) space; (2) my_mean(nums) using a numerically stable online method (e.g., Kahan or Welford) and explaining why naive summation can be inaccurate; (3) my_median(nums) for both odd and even lengths. First provide an O(n log n) solution using sorting, then implement an O(n) expected-time solution using quickselect; discuss behavior for empty lists, presence of None/NaN, and very large integers/floats; analyze time/space complexity and worst-case pitfalls.

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

Return the minimum value, or None for empty input.

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

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.

Numerically Stable Mean

Return the mean using an online update, rounded to 6 decimals.

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.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.

Median of a Numeric List

Return the median after sorting, or None for empty input.

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.

Hints

  1. Use deterministic tie-breaking for prompts with multiple valid outputs.
  2. For design-style APIs, simulate operations with explicit inputs.

Loading coding console...