Implement an Iterator Next Method
Problem statement
Implement an iterator over the supplied integer sequence. The iterator stores its current position. Every call to its next method returns the next value in the original order and advances by one. Once no values remain, it is exhausted and every later next call must continue to signal exhaustion.
For this exercise, initialize one iterator from values and make exactly nextCalls calls to it. Return one string per call: the yielded integer in decimal form, or STOP when that call finds the iterator exhausted. In Python, the iterator method should use the standard StopIteration exception, which the practice adapter converts to STOP; other languages should expose the same observable sequence.
Keep repeated values as separate iterator items. The input sequence is not modified.
Function
iterateNextCalls(values: int[], nextCalls: int) → String[]Examples
Example 1
values = [4,-2,4]nextCalls = 5return = ["4","-2","4","STOP","STOP"]The first three calls consume the three values. Both later calls observe the same exhausted state.
Example 2
values = []nextCalls = 2return = ["STOP","STOP"]An empty sequence is exhausted before the first call and remains exhausted.
Example 3
values = [0,9]nextCalls = 1return = ["0"]The single call consumes only the first value; there is no request to exhaust the iterator.
Constraints
0 <= values.length <= 100000-10^9 <= values[i] <= 10^90 <= nextCalls <= 100000