Print All Diagonals of a given matrix

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

Print All Diagonals of Matix 2


We will solve this problem in two parts. first half of diagonals and second half of diagonals.

See the code for more understanding, its self explanatory.

Complete Code:


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

Top Companies Interview Questions..-

Google Microsoft Amazon Facebook more..

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.

%d bloggers like this: