← Akuna Capital Interview Insights

Akuna Capital·Data Scientist·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Akuna Capital data scientist interview that went deep on streaming statistics, way deeper than I expected for a DS role. The whole thing was basically one extended design problem with follow-ups that kept getting harder.

Questions Asked (4)

Q1

Design a data structure that continuously ingests a stream of integers and supports querying the maximum, mean, and mode at any point. Walk through your update and query operations and their time and space complexity.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

I started with the obvious stuff: running sum and count for mean, a max-heap for maximum.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements: streaming integers, need max, mean, and mode at any time. Propose a composite data structure: a max-heap for max, running sum and count for mean, and a hash map plus a frequency-ordered structure (e.g., bucket list or heap) for mode. Analyze each operation's time and space complexity, and discuss trade-offs between update and query efficiency.

Pro tip: Emphasize that mode is the trickiest: using a hash map alone gives O(1) update but O(distinct) query; a heap or bucket approach can give O(1) query at the cost of update complexity. Discuss the trade-off explicitly to show depth.

1. Clarify requirements and constraints

Ask about data volume, whether deletions are needed, and if queries are frequent. This determines whether to optimize for update or query.

2. Design for max and mean

Use a max-heap for O(log n) update and O(1) query for max; maintain running sum and count for O(1) update and query for mean.

3. Design for mode

Use a hash map to track frequencies. For efficient mode query, maintain a bucket list (array of sets) where index is frequency, or a max-heap of (frequency, value) pairs.

4. Analyze time and space complexity

For each operation, state the complexity: e.g., update O(log n) for heap, O(1) for mean, O(1) for mode with bucket list; query O(1) for all. Space O(n).

5. Discuss trade-offs and alternatives

Compare approaches: e.g., using a balanced BST for mode gives O(log n) update and query; bucket list gives O(1) but may need resizing. Mention potential concurrency issues if streaming.

Key Points to Mention

  • Max-heap for maximum: O(log n) insertion, O(1) peek.
  • Running sum and count for mean: O(1) update and query.
  • Hash map for frequencies plus bucket list (or heap) for mode: O(1) update and query with bucket list.
  • Space complexity: O(n) for storing all elements or O(distinct) for frequencies.
  • Trade-offs: bucket list may have many empty buckets; heap for mode gives O(log n) query.
  • Handling ties for mode: any of the most frequent values is acceptable; specify if needed.

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

Q2

If the integer values are guaranteed to fall within [1, 1001], what exact solution would you use to track the mode, and how much memory does it require?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one I actually felt okay about.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Since the integer values are bounded within [1, 1001], use a fixed-size array of 1001 counters to tally frequencies, then scan the array to find the maximum frequency and the corresponding value(s). This approach runs in O(n) time and uses O(1) memory (1001 integers, independent of input size).

Pro tip: Mention that the memory is constant because the range is fixed, but if the range were huge or sparse, a hash map would be more memory-efficient. Also, clarify whether the mode should be the smallest value in case of ties, as that affects the final scan.

1. Clarify assumptions

Confirm that the input is a stream or array of integers, and that values are guaranteed to be in [1, 1001]. Ask if the mode should be unique (e.g., smallest value in case of ties).

2. Choose data structure

Select a fixed-size array (or list) of length 1002 (to accommodate indices 1 to 1001) to count occurrences. This avoids hash map overhead and ensures O(1) access.

3. Count frequencies

Iterate through the input, incrementing the counter at the index equal to the value. This takes O(n) time.

4. Find the mode

Scan the frequency array from index 1 to 1001, tracking the maximum frequency and the corresponding value. If ties are allowed, collect all values with the maximum frequency.

5. Analyze memory

State that the array uses 1001 integers, which is O(1) memory (constant, independent of n). In practice, this is about 4 KB if using 32-bit integers.

Key Points to Mention

  • Time complexity: O(n) for counting plus O(1001) for scanning, which simplifies to O(n).
  • Space complexity: O(1) because the array size is fixed at 1001, regardless of input size.
  • Alternative: hash map uses O(k) memory where k is the number of distinct values, which could be up to 1001 but with higher constant overhead.
  • Trade-off: fixed array is faster and more memory-predictable, but only works because the range is known and small.
  • Handling ties: decide whether to return the smallest mode, all modes, or any mode; this affects the final scan.
  • Edge cases: empty input, all values same, multiple modes.

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

Q3

If the value domain is unbounded or memory is limited, how would you approximate the mode, and what accuracy trade-offs does that introduce?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

I mentioned count-min sketch and heavy hitters algorithms.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem: exact mode is impossible in one pass with limited memory, so we need an approximation algorithm. Discuss specific algorithms like Misra-Gries or Count-Min Sketch, explaining how they work and their guarantees. Then analyze the trade-offs between accuracy, memory, and update speed, and suggest how to choose parameters based on application needs.

Pro tip: Mention that for heavy hitters, Misra-Gries gives deterministic error bounds, while Count-Min Sketch is probabilistic but often more memory-efficient; showing awareness of both and when to use each demonstrates depth.

1. Clarify constraints and requirements

Ask about the data stream characteristics (e.g., frequency distribution, update rate) and the acceptable error tolerance. This determines whether a deterministic or probabilistic approach is better.

2. Choose an approximation algorithm

Select an algorithm like Misra-Gries (for frequent items) or Count-Min Sketch (for frequency estimation). Explain the core idea: maintaining a summary structure that uses sublinear memory.

3. Explain how the algorithm approximates the mode

For Misra-Gries, describe how counters are incremented and decremented, and how the final counters give candidates for heavy hitters. For Count-Min Sketch, explain how hashing and minimum over counters estimates frequencies, and how to find the max.

4. Analyze accuracy trade-offs

Discuss error bounds: Misra-Gries guarantees that any item with frequency > N/k is found, with error up to N/k. Count-Min Sketch provides probabilistic error bounds with parameters ε and δ. Trade-offs: more memory reduces error but increases cost; deterministic vs. probabilistic guarantees.

5. Recommend based on use case

Suggest which algorithm to use given typical data science scenarios (e.g., real-time monitoring vs. offline analysis) and how to tune parameters (e.g., number of counters, hash functions) to balance accuracy and resources.

Key Points to Mention

  • Misra-Gries algorithm and its deterministic error guarantee
  • Count-Min Sketch and its probabilistic error bounds (ε, δ)
  • Space complexity: O(1/ε) for Misra-Gries, O(1/ε log 1/δ) for Count-Min Sketch
  • Trade-off between accuracy and memory: larger sketches yield better accuracy
  • Handling unbounded domain: hashing or frequency estimation without storing all distinct values
  • Comparison to exact mode: exact requires O(distinct) memory, approximation uses sublinear memory

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

Q4

Extend the design to support querying max, mean, and mode over only the most recent k elements as a sliding window. How do you maintain these statistics as the window moves, what is the complexity, and how do you handle ties and empty windows?

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

This is where I started to feel the pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data types and update pattern (streaming vs batch), then propose data structures tailored to each statistic: a monotonic deque for max, a running sum for mean, and a frequency map with a max-heap or bucket structure for mode. Explain how each updates in O(1) amortized time as the window slides, and discuss tie-breaking and empty window handling.

Pro tip: Emphasize that mode is the hardest to maintain efficiently; discuss the trade-off between exact O(1) updates with a heap and approximate or lazy deletion strategies. Also, mention that in practice, you might use a combination of data structures and that the choice depends on the query frequency and update rate.

1. Clarify requirements and assumptions

Ask about data types (integers, floats, strings?), whether the window size k is fixed, and if updates are streaming or batch. Confirm that we need to support queries at any time, not just after each update.

2. Design for max: monotonic deque

Maintain a deque of indices with decreasing values. When a new element arrives, pop from the back while it's smaller, then push. When the window slides, remove indices that fall out. This gives O(1) amortized per update and O(1) query for max.

3. Design for mean: running sum

Keep a running sum of the window. On each update, add the new element and subtract the element leaving the window. Mean is sum/k (or sum/window_size if window not full). O(1) per update and query.

4. Design for mode: frequency map + max-heap or buckets

Maintain a frequency map of elements in the window. To get mode, use a max-heap keyed by frequency (with lazy deletion) or a bucket structure mapping frequency to set of elements. Update frequencies on add/remove. Discuss tie-breaking (e.g., smallest value, most recent, etc.) and empty window (return None or raise exception).

5. Analyze complexity and trade-offs

Summarize: max O(1) amortized, mean O(1), mode O(log n) with heap or O(1) with buckets if frequencies bounded. Discuss memory O(k). Mention that mode with ties may require additional logic and that exact mode maintenance can be costly; consider approximate algorithms if scale is large.

Key Points to Mention

  • Monotonic deque for sliding window maximum: O(1) amortized per update, O(1) query.
  • Running sum for mean: O(1) update and query, but watch for floating-point precision issues.
  • Mode maintenance: frequency map plus max-heap with lazy deletion (O(log n) per update) or bucket approach (O(1) if frequencies bounded).
  • Tie-breaking: define a rule (e.g., smallest value, most recent, or any) and ensure consistency; may need to store additional metadata.
  • Empty window: return None, raise an exception, or define a default; clarify with interviewer.
  • Complexity summary: O(1) amortized for max and mean, O(log n) or O(1) for mode; memory O(k).

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