# Category Archives: Matrix

## Inplace (Fixed space) M x N size matrix transpose | UpdatedOctober 16, 2012

About four months of gap (missing GFG), a new post. Given an M x N matrix, transpose the matrix without auxiliary memory.

## Print unique rows in a given boolean matrixSeptember 28, 2012

Given a binary matrix, print all unique rows of the given matrix.

## Find the row with maximum number of 1sSeptember 23, 2012

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.

## Magic SquareJuly 25, 2012

A magic square of order n is an arrangement of n^2 numbers, usually distinct integers, in a square, such that the n numbers in all rows,

## Dynamic Programming | Set 8 (Matrix Chain Multiplication)February 2, 2012

Given a sequence of matrices, find the most efficient way to multiply these matrices together.

## Dynamic Programming | Set 6 (Min Cost Path)October 30, 2011

Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from (0, 0). Each cell of the matrix represents a cost to traverse through that cell.

## A Boolean Matrix QuestionOctober 18, 2011

Given a boolean matrix mat[M][N] of size M X N, modify it such that if a matrix cell mat[i][j] is 1 (or true) then make all the cells of ith row and jth column as 1.

## Print a given matrix in spiral formAugust 20, 2011

Given a 2D array, print it in spiral form. See the following examples.

## Search in a row wise and column wise sorted matrixMarch 10, 2011

Given an n x n matrix, where every row and column is sorted in increasing order. Given a number x, how to decide whether this x is in the matrix. The designed algorithm should have linear time complexity.

## Turn an image by 90 degreeFebruary 4, 2011

Given an image, how will you turn it by 90 degrees? A vague question. Minimize the browser and try your solution before going further.

## Maximum size square sub-matrix with all 1sApril 4, 2010

Given a binary matrix, find out the maximum size square sub-matrix with all 1s. For example, consider the below binary matrix. We strongly recommend that you click here and practice it, before moving on to the solution. Algorithm: Let the given binary matrix be M[R][C]. The idea of the algorithm is to construct an auxiliary… Read More »