Implement a Lazy Union Iterator Over Two Strictly Sorted Iterators

Quick Overview

Implement a UnionIterator that lazily merges two strictly sorted iterators of integers or strings into one strictly sorted iterator without duplicates, using constant extra memory. Tests iterator protocol design, one-element lookahead, cross-input deduplication, end-of-stream behavior and edge cases such as empty inputs.

Implement a Lazy Union Iterator Over Two Strictly Sorted Iterators

Company: MongoDB

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

Overview: Implement a UnionIterator that lazily merges two strictly sorted iterators of integers or strings into one strictly sorted iterator without duplicates, using constant extra memory. Tests iterator protocol design, one-element lookahead, cross-input deduplication, end-of-stream behavior and edge cases such as empty inputs.

Read the full MongoDB Software Engineer interview experience this question came from

MongoDB logo
MongoDB
Sep 27, 2026
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
15
0
Loading...