Requirements
- The first input row provides
matrix_row followed by matrix_col.
- Read the matrix from the following
N rows, with each row containing M integers separated by spaces.
- Output all
N * M matrix values as a space-delimited zigzag sequence.
- Begin in the upper-left corner, traverse anti-diagonals, and reverse the travel direction after each diagonal.
Examples
Input:
3 3
10 11 12
13 14 15
16 17 18
Output:
10 11 13 16 14 12 15 17 18
Notes
- Although the original labeling compares this to a LeetCode 53-like variation, the displayed traversal is an anti-diagonal zigzag, not a spiral traversal. Use the ordering illustrated by the example.