MongoDB logo

MongoDB Interview Question Bank

MongoDB interviews favor practical, database-flavored coding over puzzle-style problems, and judge candidates on production-quality code rather than just a working answer. Concurrency is a recurring theme across coding, code-review and design rounds, and low-level teams probe operating-system and networking internals in depth.

Coding problems
13
Before you start
Showing 12 of 12
Coding
MediumFree preview

Union of Two Sorted Iterators

Implement a UnionIterator over two ascending-sorted iterators exposing hasNext()/next() (sometimes named getNext()). Output must be globally ascending, read lazily one element at a time, and in most versions de-duplicated across the two inputs. Follow-up: generalize to K sorted iterators without materializing the data (K-way merge with a heap). Inputs are strictly sorted and may hold integers or strings.

SWE
iterator
merge
deduplication
heap
+1
5 related discussions