Thumbtack | Phone | Distinct Union Iterator
Anonymous User
1344

An Iterator that takes in two Iterator sources and emits the distinct items in the union of the sources.

class DistinctUnionIterator implements Iterator<Integer> {
	public DistinctUnionIterator(Iterator<Integer> source1, Iterator<Integer> source2) {
	}

	public boolean hasNext() {
	}

	public Integer next() {
	}
}

Example: source1 is an iterator that emits [2, 5, 2, 2, 6, 1] and source2 is an iterator that emits [3, 3, 1, 7, 2]. A
DistinctUnionIterator with these two sources should emit [7, 1, 2, 5, 3, 6] (though not necessarily in that order).

Comments (1)