MATZIGZAG - Editorial

Prerequisites: Matrix, Loops.

Problem:
Given an N x M matrix, print its elements in zig-zag fashion, alternating between left-to-right and right-to-left traversal for each row.

Solution Approach:
Traverse each row of the matrix. For even-indexed rows (starting from 0), print the elements left-to-right. For odd-indexed rows, print the elements right-to-left.

Time Complexity: O(N * M)

Space Complexity: O(1) as no additional space was allocated.