You are given a grid of size
Traverse the grid in a zigzag order according to the following process:
Start at the top left cell of the grid.
Move from left to right on even indexed rows (starting with row
Move from right to left on odd indexed rows.
Alternate directions for each consecutive row until all elements have been traversed.
Include every alternating element in the result, starting by including the very first cell visited.
Return an array of integers containing the collected values in the order they were visited.
Constraints:
grid.length
grid[i].length
grid[i][j]
You are given a grid of size
Traverse the grid in a zigzag order according to the following process:
Start at the top left cell of the grid.
Move from left to right on even indexed rows (starting with row
Move from right to left on odd indexed rows.
Alternate directions for each consecutive row until all elements have been traversed.
Include every alternating element in the result, starting by including the very first cell visited.
Return an array of integers containing the collected values in the order they were visited.
Constraints:
grid.length
grid[i].length
grid[i][j]