A Boolean Matrix QuestionGiven a boolean matrix mat where each cell contains either 0 or 1, the task is to modify it such that if a matrix cell matrix[i][j] is 1 then all the cells in its ith row and jth column will become 1.Examples:Input: [[1, 0], [0, 0]]Output: [[1, 1], [1, 0]]Input: [[1, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0
15+ min read
Maximum size rectangle binary sub-matrix with all 1sGiven a 2d binary matrix mat[][], the task is to find the maximum size rectangle binary-sub-matrix with all 1's. Examples: Input: mat = [ [0, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 0] ]Output : 8Explanation : The largest rectangle with only 1's is from (1, 0) to (2, 3) which is[1, 1, 1, 1][
15 min read
K'th element in spiral form of matrixGiven a matrix of size n * m. You have to find the kth element which will obtain while traversing the matrix spirally starting from the top-left corner of the matrix.Examples:Input: mat[][] = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ], k = 4Output: 6Explanation: Spiral traversal of matrix: {1, 2, 3, 6, 9,
13 min read
Maximum sum square sub-matrix of given sizeGiven a 2d array mat[][] of order n * n, and an integer k. Your task is to find a submatrix of order k * k, such that sum of all the elements in the submatrix is maximum possible.Note: Matrix mat[][] contains zero, positive and negative integers.Examples:Input: k = 3mat[][] = [ [ 1, 2, -1, 4 ] [ -8,
15+ min read
Minimum Initial Points to Reach DestinationGiven a m*n grid with each cell consisting of positive, negative, or no points i.e., zero points. From a cell (i, j) we can move to (i+1, j) or (i, j+1) and we can move to a cell only if we have positive points ( > 0 ) when we move to that cell. Whenever we pass through a cell, points in that cel
15+ min read
Program for Sudoku GeneratorGiven an integer k, the task is to generate a 9 x 9 Sudoku grid having k empty cells while following the below set of rules:In all 9 submatrices 3x3, the elements should be 1-9, without repetition.In all rows, there should be elements between 1-9, without repetition.In all columns, there should be e
15+ min read