You are given a square matrix grid of size n x n. Your task is to generate a new matrix maxLocal of size (n - 2) x (n - 2) where each element maxLocal[i][j] represents the largest value from a 3 x 3 submatrix in grid centered at (i + 1, j + 1). In other words, for each element of the new matrix, find the maximum value from its surrounding 3 x 3 region in the original grid.
You are given a binary matrix matrix of size m x n and an integer numSelect. Your goal is to select exactly numSelect distinct columns from the matrix such that you cover as many rows as possible. A row is considered covered if all the 1’s in that row are included in the selected columns. If a row has no 1’s, it is also considered covered.
You are given a matrix of integers. An hourglass is defined as a pattern of elements in the matrix where the middle element is surrounded by 3 elements above it and 3 elements below it, forming the shape of an hourglass. Your task is to find the maximum sum of all hourglasses that can be formed within the matrix.
You are given an m x n binary matrix grid. You need to create a difference matrix diff where each element diff[i][j] is calculated by summing the number of ones and subtracting the number of zeros in the respective row and column.
You are given a matrix grid with positive integers. In each operation, remove the greatest value from each row, and if multiple elements have the same greatest value, remove any one of them. After removing the greatest value from all rows, add the maximum of these values to the answer. The number of columns decreases by one after each operation. Perform these operations until the grid is empty, and return the sum of the maximum values from all operations.
You are given a positive integer n representing the size of an n x n matrix initially filled with zeros, and a 2D integer array queries. Each query consists of four integers [row1, col1, row2, col2]. For each query, add 1 to every element in the submatrix from (row1, col1) to (row2, col2) in the matrix. Return the matrix after applying all queries.