# Category Archives: Matrix

## Count of all subsequences having adjacent elements with different parity

Given an array arr[] of size N, the task is to find the number of non-empty subsequences from the given array such that no two… Read More »

## 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… Read More »

## Count of ways to generate a Matrix with product of each row and column as 1 or -1

Given two integers N and M, the task is to find the numbers of ways to form a matrix of size N * M consisting… Read More »

## Sorting boundary elements of a matrix

Given a matrix mat[][] of size M*N, the task is to sort only the border elements of the matrix in the clockwise direction and print… Read More »

## Color a grid such that all same color cells are connected either horizontally or vertically

Given three integers R, C, N, and an array arr[] of size N. The task is to color all cells of a grid of R… Read More »

## Find if there is a path between two vertices in a directed graph | Set 2

Given a Directed Graph and two vertices in it, check whether there is a path from the first given vertex to second. Example: Consider the… Read More »

## Count of ways to select K consecutive empty cells from a given Matrix

Given a binary matrix V[][] of dimensions N * M, wherein each cell is either empty or blocked marked by a 0 and 1 respectively,… Read More »

## Check if a graph is Strongly, Unilaterally or Weakly connected

Given an unweighted directed graph G as a path matrix, the task is to find out if the graph is Strongly Connected or Unilaterally Connected… Read More »

## Minimum number of points required to cover all blocks of a 2-D grid

Given two integers N and M. The task is to find the minimum number of points required to cover an N * M grid. A… Read More »

## Final direction after visiting every cell of Matrix starting from (0, 0)

Given a 2D grid of size N x M. The task is to find the final direction after visiting every cell under given conditions. You… Read More »

## Arrange numbers 1 to N^2 in a Zig-Zag Matrix in ascending order

Given a positive integer N, the task is to print an N × N zig-zag matrix consisting of numbers from 1 to N2, such that… Read More »

## Sum of main diagonal elements in a Matrix which are prime

Given a matrix mat[][] of R rows and C columns. The task is to find the sum of all elements from the main diagonal which… Read More »

## Program for Conway’s Game Of Life | Set 2

Given a binary grid[ ][ ] of size N*M, with each cell containing either 0 or 1, where 1 represents an alive cell and the… Read More »

## Min number of moves to traverse entire Matrix through connected cells with equal values

Given a matrix A[][] of dimensions N*M, the task is to find the minimum number of moves required to traverse the entire matrix starting from… Read More »

## Check if the Matrix follows the given constraints or not

Given a matrix A[][] of size N*M, the task is to check if the given matrix satisfies the following two conditions or not: Sum of… Read More »