Your question is Custom Array Iterator Implementation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Nutanix Prism Central may process arrays of events incrementally rather than loading each result into a separate workflow. Implement a stateful array iterator that supports sequential reads, lookahead, exhaustion checks, and resetting to the beginning.
Create an ArrayIterator class with these methods:
next(): Return the next integer and advance the cursor. Return None when the iterator is exhausted.peek(): Return the next integer without advancing the cursor. Return None when exhausted.has_next(): Return True if another element can be read, otherwise False.reset(): Move the cursor back to the first element. This method returns None.For automated evaluation, implement run_iterator_operations(values, operations). It should create one iterator, execute each operation in order, and return the result from every operation. Each operation is one of "next", "peek", "has_next", or "reset".
values, a list of integers, and operations, a list of valid operation strings.None.values.def run_iterator_operations(values, operations):