AlgoUniversity
  • Go Back
Matrix Diagnol Traversal :

Difficulty Level : Easy

Submissions : 30

Asked In :

Marks :10

: 1 | : 0

Given a 2D Matrix of integers, print all its element if you start traverse diagonally starting from $(0,0)^{th}$ element.

$1 \leq N, M \leq 10^{4}$

$1 \leq N x M \leq 10^{4}$

$1 \leq Matrix Element \leq 10^{4}$

INPUT

The first line contains two integers $N$ $M$ - number of rows and columns of matrix respectively.

The next $N$ lines contain $M$ integers each representing the Matrix.

OUTPUT

Print a single line listing all matrix elements that we visit in order as described in problem.

EXAMPLE

Sample 1 INPUT:
3 3
1 2 3
4 5 6
7 8 9
Sample 1 OUTPUT:
1 2 4 7 5 3 6 8 9
ExplanationRefer illustration attached in problem statement.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.