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
November 29, 20260
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
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- 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 ProblemsSample 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...