Maximum trace possible for any sub-matrix of the given matrix

Given an N x N matrix mat[][], the task is to find the maximum trace possible for any sub-matrix of the given matrix. Examples: Input:… Read More »

Check if matrix can be converted to another matrix by transposing square sub-matrices

Given two N X M matrices of integers. In an operation, we can transpose any square sub-matrix in matrix1. The task is to check if… Read More »

Check if Matrix remains unchanged after row reversals

Given a NxN matrix. The task is to check if after reversing all of the rows of the given Matrix, the matrix remains same or… Read More »

How to read a Matrix from user in Java?

Given task is to read a matrix from the user. The size and number of elements of matrices are to be read from the keyboard.… Read More »

Maths behind number of paths in matrix problem

The problem is to count all the possible paths from top left to bottom right of an m*n matrix with the constraints that from each… Read More »

Minimum distance to the corner of a grid from source

Given a binary grid of order r * c and an initial position. The task is to find the minimum distance from the source to… Read More »

Number of connected components in a 2-D matrix of strings

Given a 2-D matrix mat[][] the task is count the number of connected components in the matrix. A connected component is formed by all equal… Read More »

Sum of Bitwise-OR of all Submatrices

Given a NxN matrix, the task is to find the sum of bit-wise OR of all of its rectangular sub-matrices. Examples: Input : arr[][] =… Read More »

Sum of bitwise AND of all submatrices

Given a NxN matrix, the task is to find the sum of bit-wise AND of all of its rectangular sub-matrices. Examples: Input : arr[][] =… Read More »

Count possible moves in the given direction in a grid

Given a grid N x M size and initial position (X, Y) and a series of K moves. Each move contains 2 integers Dx and… Read More »

Number of submatrices with OR value 1

Given a N*N binary matrix, task is to find the count of rectangular sub-matrices with OR value 1. Examples: Input : arr[][] = {{0, 0,… Read More »

XOR of XORs of all sub-matrices

Given a ‘N*N’ matrix, the task is to find the XOR of XORs of all possible sub-matrices. Examples: Input :arr = {{3, 1}, {1, 3}}… Read More »

Number of submatrices with all 1s

Given a N*N matrix containing only 0s and 1s, the task is to count the number of submatrices containing all 1s. Examples: Input : arr[][]… Read More »

XOR of a submatrix queries

Given an N * N matrix and q queries, each containing position of top-left and bottom-right corner of a rectangular sub-matrix, the task is to… Read More »

Sum of all Submatrices of a Given Matrix

Given a NxN 2-D matrix, the task to find the sum of all the submatrices. Examples: Input : arr[] = {{1, 1}, {1, 1}}; Output… Read More »