# Matrix

### Find regions with most common region size in a given boolean matrix

#include using namespace std;#define ROW 4#define COL 5  int isSafe(int M[][COL], int row, int col,           bool visited[][COL]){    return (row >= 0) && (row <…

### Rabbit House | Google Kickstart 2021 Round A

#include using namespace std;  void solve(long long int r, long long int c,           vector& grid){    priority_queue        pq;      for (long long int i = 0; i…

### Maximize matrix sum by flipping the sign of any adjacent pairs

Given a matrix mat[] of dimension N*N, the task is to find the maximum sum of matrix elements by flipping…

### Maximum sum of K elements selected from a Matrix

#include using namespace std;int maximumSum(vector& prefixSum,               vector& dp,               int K, int N, int rem, int id){        int ans = INT_MIN;        if (rem == 0)        return…

### Maximum points by traversing from top left of Matrix to bottom right by two persons

#include using namespace std;  const static int MAXR = 20, MAXC = 20;int cache[MAXC][MAXR][MAXC][MAXR],    dp[MAXC][MAXR][MAXC][MAXR];int n, m;vector grid;  int maxMoney(int x1, int y1,…

### Count cells in a grid from which maximum number of cells can be reached by K vertical or horizontal jumps

Given a matrix mat[][] of dimensions N*M and a positive integer K, the task is to find the number of…

### Generate an N-length array having GCD of all its pairs present in a given 2D array

Given a 2D array arr[][] consisting of N*N positive integers, the task is to generate an N-length array such that…

### TCS CodeVita 9 ( Zone 1) 2020 | Constellation

#include using namespace std;  void printGalaxy(    vector mat, int n){          for (int i = 0; i < n; i++) {                          if (mat[0][i] == '#'            &&…