Round-Robin Iterator Across Several Regional Trip Feeds

Last updated: November 29, 2026

Quick Overview

Implement an iterator that takes k lists of trip records from regional feeds and yields records in round-robin order (first from feed 0, then feed 1, and so on), skipping feeds once they are exhausted.

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

0

0

0 solved


Implement an iterator that takes k lists of trip records from regional feeds and yields records in round-robin order (first from feed 0, then feed 1, and so on), skipping feeds once they are exhausted.

An iterator design warm-up in the style of Uber's phone screens, motivated by fairly interleaving work from several city shards. The interviewer looks for lazy iteration over input iterators rather than copying everything into one list.

What the Interviewer Expects
  • Keeps a queue of (feed index, iterator) pairs
  • Removes a feed as soon as it is exhausted
  • Works lazily on iterators, not only lists
  • Implements has_next and next with clear contracts
  • Handles empty feeds at construction
Key Topics to Cover
Iterators
Queues
Round robin
Lazy evaluation
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 weight feeds so busy regions get two turns for every one of a quiet region?
  • How would you make this thread-safe for multiple consumers?
  • How would you resume the iterator after a process restart?
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

Input: list of iterables. API: has_next() and next(); next() raises StopIteration when empty. Feeds can be generators, so we cannot rely on len....

High-Level Design

Store a deque of active iterators. To fetch the next record, pop the front iterator and try to take its next element. If it yields, push the iterator to the back and return the element. If it is exhau...


Submit Your Answer
Markdown supported