540.Zigzag Iterator
1.Description(Medium)
v1 = [1, 2]
v2 = [3, 4, 5, 6]2.Code
public class ZigzagIterator {
/**
* @param v1 v2 two 1d vectors
*/
public ZigzagIterator(List<Integer> v1, List<Integer> v2) {
// initialize your data structure here.
}
public int next() {
// Write your code here
}
public boolean hasNext() {
// Write your code here
}
}
/**
* Your ZigzagIterator object will be instantiated and called as such:
* ZigzagIterator solution = new ZigzagIterator(v1, v2);
* while (solution.hasNext()) result.add(solution.next());
* Output result
*/Last updated