PracHub
QuestionsCoachesLearningGuidesInterview Prep

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.

Yield favorites then photos, excluding blocked IDs and duplicates.

Examples

Input: ([3, 1, 2, 3], [2, 4, 1, 5], {4})

Expected Output: [3, 1, 2, 5]

Explanation: Prompt example.

Input: ([], [1, 1], set())

Expected Output: [1]

Explanation: Duplicates in photos.

Input: ([{'id': 'a'}], [{'id': 'a'}, {'id': 'b'}], {'b'})

Expected Output: ['a']

Explanation: Object IDs.

Last updated: Jun 27, 2026

Loading coding console...

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
  • AI Coding 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.

Related Coding Questions

  • Infection Spread on a Grid (Cellular Automaton) - Google (hard)
  • Most Active Users in a Live Communication Stream - Google (medium)
  • Boolean Expression Tree with Leaf Flips - Google (medium)
  • Streaming Points: Remove Any Pair Within a Distance - Google (medium)
  • Solve Rooms and Top-K Streams - Google (medium)