Follow up Zigzag Iterator: What if you are given k 1d vectors? How well can your code be extended to such cases? The “Zigzag” order is not clearly defined and is ambiguous for k > 2 cases. If “Zigzag” does not look right to you, replace “Zigzag” with “Cyclic”.
Example
No.1
Input: k = 3
1 | vecs = [ |
Output: [1,4,8,2,5,9,3,6,7]
No.2
Input: k = 3
1 | vecs = [ |
Output: [1,2,3,1,2,3,1,2,3]
code
1 | private Queue<Iterator> queue = new LinkedList<>(); |