Count of submatrix with sum X in a given Matrix
Given a matrix of size N x M and an integer X, the task is to find the number of sub-squares in the matrix with sum of elements equal to X.Examples:...
read more
Maximum sum submatrix
Prerequisite: Kadane’s algorithm...
read more
Check if a matrix contains a square submatrix with 0 as boundary element
Given an N*N binary matrix arr[][], the task is to check if the matrix contains a square of at least size 2 x 2 whose boundaries are made up of only 0s....
read more
Count of Rectangles with area K made up of only 1s from given Binary Arrays
Given two binary arrays A[] and B[], of length N and M respectively, the task is to find the number of rectangles of area K consisting of 1‘s in the matrix C[][] generated by multiplying the two arrays such that, C[i][j] = A[i] * B[j] (1< i < n, 1< j < m)....
read more
Minimum area such that all submatrix of the size have same maximum value
Given an N*M matrix Mat[][] containing all distinct integers, the task is to find the minimum area of the matrix (r*c, where 1 ≤ r ≤ N and 1 ≤ c ≤ M ) for every submatrix of size r*c the maximum value remains the same....
read more
Largest row-wise and column-wise sorted sub-matrix
Given an N * M matrix mat[][], the task is to find the area-wise largest rectangular sub-matrix such that each column and each row of the sub-matrix is strictly increasing....
read more
Binary Matrix after flipping submatrices in given range for Q queries
Given a binary matrix arr[][] of dimensions M x N and Q queries of the form (x1, y1, x2, y2), where (x1, y1) and (x2, y2) denotes the top-left and bottom-right indices of the submatrix required to be flipped(convert 0s to 1s and vice versa) respectively. The task is to print the final matrix obtained after performing the given Q queries....
read more
Check if given Sudoku solution is valid or not
Given a 2D array, board[][] of size 9 × 9, which represents a solution to the Sudoku puzzle, the task is to check if the given representation of a solved Sudoku puzzle is valid or not....
read more
Smallest submatrix with Kth maximum XOR
Given a matrix m[][] of dimensions N × M and an integer K, calculate XOR(i, j) which is equal to the Bitwise Xor of all elements of submatrix from indices (1, 1) to (i, j)), for every index of the matrix. The task is to find the submatrix {(1, 1), …, (i, j)} having Kth maximum XOR(i, j) value. If multiple such submatrices exist, then print the smallest one....
read more
Count all square sub-matrix with sum greater than the given number S
Given a matrix mat[][] and two integers K and S, the task is to count all K x K sub-matrix such that the sum of all the elements in the sub-matrix is greater than or equal to S....
read more
Maximum sum of any submatrix of a Matrix which is sorted row-wise and column-wise
Given a matrix mat[][] whose elements are sorted both row-wise and column-wise. The task is to find the maximum sum of any submatrix from the given matrix mat[][]....
read more
Construct a Matrix such that each cell consists of sum of adjacent elements of respective cells in given Matrix
Given a matrix arr[][] of dimensions N * M, the task is to generate a matrix such that any cell (r, c) stores the sum of adjacent elements present horizontally, vertically, and diagonally in the given matrix....
read more