L541Zigzag Iterator II
Follow upZigzag Iterator: What if you are givenk
1d vectors? How well can your code be extended to such cases? The "Zigzag" order is not clearly defined and is ambiguous fork > 2
cases. If "Zigzag" does not look right to you, replace "Zigzag" with "Cyclic".
Example
Givenk = 3
1d vectors:
Return[1,4,8,2,5,9,3,6,7]
.
这题是上一题的扩展。这里我用了一条list来记录所有行的iterator。然后一个一个call(用mod来控制cycle)。主要注意打完了一行以后得处理一下怎样取模。
Last updated