![]() |
VOOZH | about |
Given a 2D array, print it in zigzag form. Examples :
Input : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Output : 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 20 19 18 17 16 Input : 10 24 32 50 6 17 99 10 11 Output : 10 24 32 17 6 50 99 10 11
1 2 3 4 5 10 9 8 7 6 11 12 13 14 15
Time Complexity: Time complexity of the above solution is O(row*column).
Space Complexity: O(1)
Related Articles: