← Atlassian Interview Insights

Atlassian·Machine Learning Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Atlassian ML engineer interview with a sliding window coding problem. Pretty standard stuff but the implementation details tripped me up more than I expected.

Questions Asked (1)

Q1

Design a MovingAverage class that takes a window size on initialization and supports a next() method which appends a new integer to the stream and returns the average of the most recent N values.

Algorithms & Data Structures
Author's notes

Felt fine about the core idea (circular buffer or a deque), but I fumbled the edge case where the stream hasn't filled up to the window size yet.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: window size N, integer stream, and return type (float). Then design a class using a queue (or circular buffer) to maintain the last N values and a running sum to compute the average in O(1) time per next() call. Discuss edge cases like initial fill and integer overflow.

Pro tip: Mention that using a running sum avoids O(N) recomputation, and handle the initial phase when fewer than N values have been seen by dividing by the current count. Also, note that for ML applications, this is a streaming average which can be extended to weighted averages or exponential moving averages.

1. Clarify requirements and constraints

Ask about window size (fixed or dynamic), data type (integers), return type (float), and behavior when fewer than N elements have been added. Confirm if thread safety is needed.

2. Choose data structures

Use a queue (e.g., collections.deque in Python) to store the last N elements, and maintain a running sum variable. Alternatively, use a circular buffer for fixed-size efficiency.

3. Implement next() method

Append the new value to the queue and add to sum. If queue size exceeds N, remove the oldest element and subtract from sum. Return sum / min(queue size, N) as a float.

4. Analyze complexity and edge cases

Time complexity: O(1) per next() call. Space: O(N). Handle edge cases: N=0 (invalid), negative numbers, large sums (use float or handle overflow).

5. Test with examples

Walk through a sample: MovingAverage(3), next(1) -> 1.0, next(10) -> 5.5, next(3) -> 4.666..., next(5) -> 6.0. Verify correctness.

Key Points to Mention

  • Use a queue (FIFO) to maintain the sliding window of recent values.
  • Maintain a running sum to achieve O(1) time per next() call.
  • Handle the initial phase when fewer than N values have been seen by dividing by the current count.
  • Consider integer overflow for large streams; use a wider type or float for sum.
  • Discuss space complexity O(N) and potential optimizations like circular buffer.
  • Mention that this is a common streaming average pattern in ML for online metrics.

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