PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

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.

  • Medium
  • Thumbtack
  • Coding & Algorithms
  • Data Scientist

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.

Input: ([1e16,1,-1e16],)

Expected Output: 0.0

Explanation: Large cancellation case.

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.

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.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Estimate Two Conditional Win Probabilities by Simulation - Thumbtack (medium)
  • Design streaming new-vs-returning monthly metrics - Thumbtack (hard)
  • Implement TF–IDF with sparse matrices - Thumbtack (medium)