← Thumbtack Interview Insights

Thumbtack·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Technical screen for a Data Scientist role at Thumbtack that went pretty deep into numerical computing fundamentals. Three Python functions, no libraries allowed, and they wanted you to actually know why naive summation breaks down. More math-y than I expected for a DS interview.

Questions Asked (4)

Q1

Implement a function my_min(nums) that returns the minimum value of a list in O(n) time and O(1) space, without using any libraries.

Algorithms & Data Structures
Author's notes

Straightforward enough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints and edge cases first, then explain that a single pass through the list while tracking the minimum achieves O(n) time and O(1) space. Write clean, library-free code and test it with representative examples, including empty and single-element lists.

Pro tip: Explicitly discuss how you handle an empty list—either raise a ValueError or return None—and mention that this is a common interview edge case. Also, note that using Python's built-in min() would violate the 'no libraries' constraint, so you must implement the loop manually.

1. Clarify requirements and edge cases

Confirm the input type (list of numbers), expected behavior for empty list, and whether the list can contain mixed types. Ask if the list is guaranteed non-empty.

2. Design the algorithm

Explain that you will initialize the minimum with the first element and iterate through the rest, updating the minimum whenever a smaller value is found. This uses O(1) extra space and O(n) time.

3. Implement the function

Write the code without libraries, handling the empty list case explicitly (e.g., raise ValueError). Use a simple loop and avoid built-in functions like min().

4. Test with examples

Walk through test cases: normal list, list with negative numbers, single element, and empty list. Verify the output and discuss time/space complexity.

5. Discuss trade-offs and alternatives

Mention that this is optimal for unsorted data; if the list were sorted, the minimum would be at index 0. Also, note that using built-in min() would be simpler but violates the constraint.

Key Points to Mention

  • Time complexity: O(n) because each element is visited once.
  • Space complexity: O(1) because only a single variable is used to track the minimum.
  • Edge case: empty list should raise an error or return a sentinel value, depending on requirements.
  • No libraries: avoid using built-in functions like min(), sorted(), or numpy.
  • Initialization: start with the first element to avoid issues with infinity or None.
  • Testing: include cases with negative numbers, duplicates, and large inputs to demonstrate robustness.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Implement my_mean(nums) using a numerically stable online algorithm, and explain why straightforward summation can produce inaccurate results for floating point numbers.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I got tripped up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining the numerical stability issue with naive summation, then present a stable online algorithm like Welford's method. Implement the function clearly, and discuss trade-offs such as time complexity and numerical accuracy.

Pro tip: Mention that Welford's method is widely used in streaming data and can be extended to compute variance and standard deviation stably. Also, note that for very large datasets, a two-pass algorithm might be acceptable if memory allows, but online algorithms are preferred for streaming.

1. Explain the problem with naive summation

Describe how floating-point addition can lose precision when adding a small number to a large sum, leading to catastrophic cancellation or accumulation of rounding errors.

2. Introduce Welford's online algorithm

Present the algorithm: maintain a running mean and count, updating the mean incrementally with each new value using the formula mean += (x - mean) / n.

3. Implement my_mean

Write the function in code, ensuring it handles edge cases like empty input and uses a numerically stable update.

4. Discuss numerical stability and trade-offs

Explain why Welford's method is more stable, and compare with alternatives like Kahan summation or pairwise summation, noting their complexity and use cases.

Key Points to Mention

  • Floating-point representation and rounding errors
  • Catastrophic cancellation in naive summation
  • Welford's algorithm for online mean and variance
  • Time and space complexity of the algorithm
  • Edge cases: empty input, single element, large datasets
  • Comparison with other stable summation methods (Kahan, pairwise)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Implement my_median(nums) first with an O(n log n) sorting-based approach, then with an O(n) expected-time quickselect solution. Handle both odd and even length lists.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The sorting version was fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem requirements (odd/even handling, input types, mutability) and then implement the O(n log n) sorting-based solution as a baseline. Next, explain the quickselect algorithm for O(n) expected time, covering partitioning, pivot selection, and recursion/iteration. Finally, compare the trade-offs between the two approaches and discuss edge cases and potential optimizations.

Pro tip: Mention that quickselect has O(n) expected time but O(n^2) worst-case, and that using random pivots or median-of-medians can mitigate this. Also, note that for even-length lists, the median is the average of the two middle elements, which requires finding the kth and (k+1)th smallest elements.

1. Clarify requirements and edge cases

Ask about input constraints (e.g., list size, data types, whether the list can be modified) and confirm how to handle odd and even lengths. Discuss edge cases like empty list, single element, and duplicates.

2. Implement sorting-based approach

Write a function that sorts the list and returns the middle element for odd length or the average of the two middle elements for even length. Analyze time complexity: O(n log n) due to sorting.

3. Explain quickselect algorithm

Describe quickselect: choose a pivot, partition the array, and recursively search the side containing the kth smallest element. For even length, find both kth and (k+1)th elements and average them.

4. Implement quickselect solution

Code the quickselect function, handling partitioning and recursion (or iteration). Ensure it works for both odd and even lengths by finding the appropriate order statistics.

5. Compare trade-offs and discuss optimizations

Contrast the two approaches: sorting is simpler and deterministic but slower; quickselect is faster on average but has worst-case O(n^2). Mention pivot selection strategies (random, median-of-medians) to improve worst-case.

Key Points to Mention

  • Time complexity: O(n log n) for sorting vs O(n) expected for quickselect, with O(n^2) worst-case for quickselect.
  • Space complexity: sorting may require O(n) extra space (depending on implementation), while quickselect can be done in-place with O(1) extra space.
  • Handling even-length lists: median is average of two middle elements, requiring two order statistics.
  • Pivot selection: random pivot gives expected O(n) time; median-of-medians guarantees O(n) worst-case but with higher constant factors.
  • Edge cases: empty list, single element, all elements equal, negative numbers, floating-point numbers.
  • Stability and mutability: sorting may alter the original list; quickselect can be implemented to avoid modifying input if needed.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How should your implementations handle edge cases like empty lists, None or NaN values in the input, and very large integers or floats?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

They asked this as a follow-up across all three functions.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by emphasizing that robust edge-case handling is critical for production-grade data science code, then walk through a systematic approach: validate inputs, handle missing values explicitly, and consider numerical stability. Use concrete examples from your experience to illustrate how you've addressed these issues in practice.

Pro tip: Mention that you document edge-case behavior in docstrings and unit tests, and that you prefer explicit handling over silent failures to avoid downstream bugs. This shows you think about maintainability and collaboration.

1. Input Validation

Check for empty lists, None, or unexpected types at the start of your function and raise clear errors or return early. Use assertions or validation libraries to enforce contracts.

2. Missing Value Handling

Decide on a strategy for NaN/None: either drop, impute, or propagate with a flag. Document the choice and ensure it aligns with business logic.

3. Numerical Stability

For large integers/floats, consider overflow, precision loss, and performance. Use appropriate data types (e.g., Python's arbitrary precision ints, numpy's float64) and algorithms that avoid catastrophic cancellation.

4. Testing and Monitoring

Write unit tests for edge cases and add logging/monitoring to catch issues in production. Use property-based testing to cover a wide range of inputs.

Key Points to Mention

  • Defensive programming: validate inputs early and fail fast with informative errors.
  • Explicit handling of NaN/None: avoid silent propagation that can corrupt results.
  • Numerical precision: use appropriate types and algorithms to handle large numbers.
  • Performance implications: edge-case handling shouldn't degrade performance for common cases.
  • Documentation: clearly state assumptions and behavior for edge cases.
  • Testing: include edge cases in unit tests and consider property-based testing.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.