All Posts

Leetcode 1267: Count Servers that Communicate

You are given a 2D grid where each cell is either 1 (indicating a server) or 0 (no server). Two servers are said to communicate if they are in the same row or column. The task is to find the number of servers that can communicate with at least one other server.

Leetcode 1277: Count Square Submatrices with All Ones

Given a m x n matrix of ones and zeros, count how many square submatrices are filled with all ones.

Leetcode 1292: Maximum Side Length of a Square with Sum Less than or Equal to Threshold

You are given a matrix of integers and a threshold. Your goal is to find the maximum side length of a square where the sum of the elements inside the square is less than or equal to the threshold.

Leetcode 1314: Matrix Block Sum

Given a matrix of integers, where each element represents a value, you need to calculate the sum of all elements in a sub-matrix for each cell. For each cell, the sub-matrix includes all elements within a square grid of size (2k+1) x (2k+1) centered at that cell. If the sub-matrix extends beyond the boundaries of the matrix, only the valid elements within the matrix should be considered.

Leetcode 1329: Sort the Matrix Diagonally

You are given a matrix mat of integers with dimensions m x n. A matrix diagonal is a sequence of matrix elements that start from some cell in the topmost row or leftmost column and go diagonally towards the bottom-right corner. Your task is to sort each matrix diagonal in ascending order and return the resulting matrix.

Leetcode 1337: The K Weakest Rows in a Matrix

You are given a binary matrix where 1’s represent soldiers and 0’s represent civilians. The soldiers are positioned before the civilians in each row. A row is weaker than another if it has fewer soldiers, or if it has the same number of soldiers but appears earlier. Your task is to return the indices of the k weakest rows in the matrix, ordered from weakest to strongest.