Implement iterator merging lists with filtering
Company: Google
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
## Problem
Implement an iterator (or generator) that iterates over two input sequences:
- `favorites`: a list of item IDs (or objects with an `id` field)
- `photos`: a list of item IDs (or objects with an `id` field)
The iterator must:
1. Yield items from `favorites` first, then items from `photos`.
2. Filter out any item whose ID is in a given `blockedIds` set.
3. Ensure **no duplicates** are yielded across the combined iteration (if an ID appears multiple times in either list, yield it at most once total).
## Input / Output
- **Input:** `favorites`, `photos`, `blockedIds`
- **Output:** An iterator over IDs (or items) in the required order.
## Notes / Edge Cases
- An ID may appear in both lists; it should be yielded the first time it is encountered (after applying blocking), and skipped thereafter.
- Either list may be empty.
- All items may be blocked.
## Example
- `favorites = [3, 1, 2, 3]`
- `photos = [2, 4, 1, 5]`
- `blockedIds = {4}`
Output iteration: `3, 1, 2, 5`
Quick Answer: This question evaluates iterator/generator design, sequence merging, stateful filtering and deduplication, checking a candidate's ability to maintain input ordering while excluding blocked IDs and preventing duplicate yields.