PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Implement iterator merging lists with filtering

Last updated: May 4, 2026

Quick Overview

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.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

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.

Related Interview Questions

  • Solve Rooms and Top-K Streams - Google (medium)
  • Find Containing Range - Google (medium)
  • Rearrange Tasks With Cooldown - Google (medium)
  • Implement Employee Management and Expression Evaluation - Google (medium)
  • Solve Three Array and Matrix Path Problems - Google (medium)
Google logo
Google
Jan 6, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
3
0
Loading...

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

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.