← DRW Interview Insights

DRW·Data Scientist·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

DRW data science interview threw a pretty meaty algorithmic problem at me around rolling statistics. The whole thing felt more like a quant/engineering hybrid than a typical DS screen, which I wasn't fully prepared for.

Questions Asked (1)

Q1

Given an array of numbers and a window size k, implement an O(n) algorithm to compute the rolling standard deviation across all contiguous windows. You should update statistics incrementally rather than recomputing each window from scratch, discuss numerical stability, and handle edge cases like k <= 0, k > n, k = 1, and NaN values. Write tests too.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one took me a minute to even parse.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and edge cases, then present an O(n) algorithm using rolling sums and sums of squares with Welford's method for numerical stability. Discuss trade-offs between naive and incremental approaches, and outline a comprehensive test suite covering edge cases and numerical accuracy.

Pro tip: Explicitly mention that DRW values production-ready code, so emphasize handling NaN values by propagating them and ensuring the algorithm remains O(n) even with missing data. Also, discuss how you would validate numerical stability with tests comparing against a high-precision reference.

1. Clarify Requirements and Edge Cases

Ask clarifying questions about input types, expected output format, and how to handle edge cases like k <= 0, k > n, k = 1, and NaN values. Confirm whether the standard deviation should be population or sample.

2. Design O(n) Algorithm with Numerical Stability

Propose using rolling sums and sums of squares, but highlight the numerical instability of the naive formula. Instead, recommend Welford's online algorithm or a compensated summation approach to update mean and variance incrementally.

3. Handle Edge Cases and NaN Propagation

Define behavior for invalid k (return empty array or raise error), k=1 (std dev = 0), and NaN values (propagate NaN in windows containing NaN). Ensure the algorithm remains O(n) by tracking NaN counts.

4. Implement and Test

Write clean code with clear variable names and comments. Develop tests for normal cases, edge cases, and numerical stability (e.g., large numbers, small variance). Compare against a brute-force implementation for correctness.

5. Discuss Trade-offs and Alternatives

Mention trade-offs: Welford's method is more stable but slightly more complex; rolling sums are simpler but risk catastrophic cancellation. Discuss when to use each and potential optimizations.

Key Points to Mention

  • Welford's algorithm for numerically stable online variance computation
  • Handling NaN values by propagating them and maintaining O(n) via NaN count tracking
  • Edge case handling: k <= 0 (invalid), k > n (empty result), k = 1 (std dev = 0)
  • Population vs. sample standard deviation (divide by k or k-1)
  • Testing strategy: unit tests for edge cases, property-based tests, and comparison with brute-force
  • Time and space complexity: O(n) time, O(1) extra space (excluding output)

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