Round-Robin Iterator Over Multiple Wallet Activity Feeds

Last updated: November 29, 2026

Quick Overview

Implement an iterator that takes several possibly lazy activity feeds and yields one item from each in turn, skipping feeds as they run out, with has_next and next methods.

Coinbase
Coding & Algorithms
Software Engineer
Coinbase
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Implement an iterator that takes several possibly lazy activity feeds and yields one item from each in turn, skipping feeds as they run out, with has_next and next methods.

Coinbase's coding screens often ask candidates to build iterator classes, and a unified activity view across a user's wallets and accounts is a real product need. The interviewer checks lazy evaluation, a correct has_next that does not consume items twice, and handling of empty sources.

What the Interviewer Expects
  • Accept any iterables, not just lists
  • Use a queue of iterators and rotate after each item
  • Buffer one item so has_next is idempotent
  • Drop exhausted iterators
  • Raise StopIteration when done and support Python's iterator protocol
Key Topics to Cover
iterators and streams
queues
lazy evaluation
design a data structure
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you merge by timestamp instead of round robin?
  • How would you add a remove operation for the last returned item?
  • How do you support feeds that are paginated network calls?
  • How would you weight feeds so one appears twice as often?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Constructor takes a list of iterables. has_next() reports whether any item remains and may be called repeatedly. next() returns the next item in round-robin order and raises StopIteration when emp...

High-Level Design

Store a deque of iterators. has_next pulls from the front iterator into a one-item buffer; if that iterator is exhausted, drop it and try the next. On success, the iterator goes to the back so the n...


Submit Your Answer
Markdown supported