Search⌘ K
AI Features

Zigzag Iterator

Try to solve the Zigzag Iterator problem.

We'll cover the following...

Statement

Design an iterator class ZigzagIterator that takes two integer arrays v1 and v2 and iterates through their elements by alternating between the arrays.

The iterator must support the following methods:

  • next() returns the next integer in the alternating traversal.

  • hasNext() returns true if there is at least one remaining element to return, otherwise returns false.

When ...