Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 566 Bytes

File metadata and controls

21 lines (17 loc) · 566 Bytes

Wave Traversal

Easy


  1. You are given, no of rows(n) and no of columns(m)
  2. You are given n*m numbers, representing elements of 2d arrays.
  3. You are required to traverse and print the contents of the 2D array in form of a wave- down the first column then up the second column and so on.

Example 1:

Input:  n=3, m=4, arr[][] = {11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34}
Output:  11 21 31 32 22 12 13 23 33 34 24 14

Constraints:

1 <= n <= 10^2
1 <= m <= 10^2
-10^9 <= e1, e2, .. n * m elements <= 10^9