This post is completed by 1 user

  • 1
Add to List
Medium

205. Print All Diagonals of a given matrix

Objective: Given a two-dimensional matrix, write an algorithm to print all the diagonals of the matrix.

Print All Diagonals of Matix 2

Example:

Click here to read about solving this problem using Queue

In this article we will solve this problem in two parts. the first half of diagonals and the second half of diagonals.

See the code for more understanding, it self explanatory.

Output:

1
5 2
9 6 3
13 10 7 4
14 11 8
15 12
16