All Posts

Leetcode 2658: Maximum Number of Fish in a Grid

You are given a 2D matrix grid of size m x n, where each cell can either be a land cell (represented by 0) or a water cell (represented by a positive integer indicating the number of fish present in that cell). A fisher can start at any water cell and perform two operations any number of times: catch all the fish in the current cell or move to an adjacent water cell. Your task is to determine the maximum number of fish the fisher can catch if they start at the optimal water cell.

Leetcode 2661: First Completely Painted Row or Column

You are given a list of integers arr and a 2D matrix mat. The list arr contains all the integers from the range [1, m * n] and represents the order in which you paint the cells of mat. Each integer in arr corresponds to a cell in mat that is being painted. The goal is to find the smallest index i at which either a row or a column becomes completely painted.

Leetcode 2679: Sum in a Matrix

You are given a 2D array nums where each row represents a set of numbers. You perform operations on the matrix by removing the largest number from each row at each step. After removing the largest number from each row, you identify the highest number amongst all those removed and add it to your score. Repeat this until the matrix becomes empty and return the final score.

Leetcode 2684: Maximum Number of Moves in a Grid

You are given a matrix grid of size m x n filled with positive integers. Starting from any cell in the first column, you can move to any of the cells on the next column (right) that are strictly greater than the value of the current cell. The possible directions you can move to are: the cell directly to the right, the cell diagonally to the top-right, or the cell diagonally to the bottom-right. Your task is to return the maximum number of moves that you can perform by starting at any cell in the first column.

Leetcode 2711: Difference of Number of Distinct Values on Diagonals

Given a 2D grid of size m x n, you are tasked with finding a new matrix where each cell value is the absolute difference between the count of distinct values in the diagonal cells to the left and above it, and the count of distinct values in the diagonal cells to the right and below it.

Leetcode 2812: Find the Safest Path in a Grid

You are given a square grid of size n x n, where each cell contains either a thief (represented by 1) or is empty (represented by 0). You start at the top-left corner of the grid and must find the maximum safeness factor for a path to the bottom-right corner. The safeness factor is defined as the minimum Manhattan distance from any cell in the path to the nearest thief.