Zipped Iterator
Implement a zip iterator of two lists of integers a
and b
where
next()
polls the next element in the iterator, alternating betweena
andb
hasnext()
which returns whether the next element exists
Constraints
n ≤ 100,000
wheren
is the number of calls tonext
andhasnext
https://binarysearch.com/problems/Zipped-Iterator
Examples
Example 1
Input
- methods =
['constructor', 'hasnext', 'next', 'next', 'next', 'next', 'next', 'hasnext']
- arguments =
[[[1, 2], [3, 4, 5]], [], [], [], [], [], [], []]
Output
- answer =
[None, True, 1, 3, 2, 4, 5, False]
Leave a comment