541.Zigzag Iterator II
1.Description(Medium)
[1,2,3]
[4,5,6,7]
[8,9]2.Code
public class ZigzagIterator2 {
/**
* @param vecs a list of 1d vectors
*/
public ZigzagIterator2(ArrayList<ArrayList<Integer>> vecs) {
// initialize your data structure here.
}
public int next() {
// Write your code here
}
public boolean hasNext() {
// Write your code here
}
}
/**
* Your ZigzagIterator2 object will be instantiated and called as such:
* ZigzagIterator2 solution = new ZigzagIterator2(vecs);
* while (solution.hasNext()) result.add(solution.next());
* Output result
*/Last updated