I thought this problem is to implement an Iterator. Are we supposed to use the java class Iterator in our implementation?

Here is my 5ms AC solution (not using class Iterator).

public class ZigzagIterator {

```
int arrNum; //indicates which vector should we use next time
int[] indexArray; //index of the next val for vector[i]
List<List<Integer>> vectors;
int k;
public ZigzagIterator(List<Integer> v1, List<Integer> v2) {
k = 2;
arrNum = 0;
indexArray = new int[k];
vectors = new ArrayList<List<Integer>>();
vectors.add(new ArrayList<Integer>(v1));
vectors.add(new ArrayList<Integer>(v2));
}
public int next() {
while (indexArray[arrNum] >= vectors.get(arrNum).size()){
arrNum = (arrNum + 1) % k;
}
int res = vectors.get(arrNum).get(indexArray[arrNum]);
indexArray[arrNum]++;
arrNum = (arrNum + 1) % k;
return res;
}
public boolean hasNext() {
for (int i = 0; i < indexArray.length; i++){
if (indexArray[i] < vectors.get(i).size()){
return true;
}
}
return false;
}
```

}