Category Archives: Matrix

Print cells with same rectangular sums in a matrix

Given a matrix of m x n matrix, we need to print all those cells at which sum of sub-matrix ended at this cell and sub-matrix starting at this cell is equal to remaining elements. For better understanding please see below diagram, Examples: Input : mat[][] = {1, 2, 3, 5, 4, 1, 0, 2,… Read More »

Print matrix in diagonal pattern

Given a matrix of n*n size, the task is to print its elements in diagonally pattern. Input : mat[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} Output : 1 2 4 7 5 3 6 8 9. Explanation: We start from 1 Then from upward to downward diagonally i.e. 2 and 4… Read More »