原文链接: https://leetcode-cn.com/problems/subrectangle-queries 英文原文Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods: 1. updateSubrectangle(int row1, int co…
标签详情
矩阵 分类
原文链接: https://leetcode-cn.com/problems/count-submatrices-with-all-ones 英文原文Given an m x n binary matrix mat, return the number of submatrices that have all ones. Example 1: Input: mat = [[1,0,1],[1,1,0],[1,1,0]] Output: 13 Explanation: There are 6 re…
原文链接: https://leetcode-cn.com/problems/minimum-swaps-to-arrange-a-binary-grid 英文原文Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them. A grid is said to be valid if all the cells above the main diagonal …
原文链接: https://leetcode-cn.com/problems/detect-cycles-in-2d-grid 英文原文Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid. A cycle is a path of length 4 or more in the grid …
原文链接: https://leetcode-cn.com/problems/matrix-diagonal-sum 英文原文Given a square matrix mat, return the sum of the matrix diagonals. Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are…
原文链接: https://leetcode-cn.com/problems/minimum-number-of-days-to-disconnect-island 英文原文Given a 2D grid consisting of 1s (land) and 0s (water). An island is a maximal 4-directionally (horizontal or vertical) connected group of 1s. The grid is said to …
原文链接: https://leetcode-cn.com/problems/strange-printer-ii 英文原文There is a strange printer with the following two special requirements: On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up t…
原文链接: https://leetcode-cn.com/problems/special-positions-in-a-binary-matrix 英文原文Given a rows x cols matrix mat, where mat[i][j] is either 0 or 1, return the number of special positions in mat. A position (i,j) is called special if mat[i][j] == 1 and …
原文链接: https://leetcode-cn.com/problems/find-valid-matrix-given-row-and-column-sums 英文原文You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the eleme…
原文链接: https://leetcode-cn.com/problems/minimum-cost-to-connect-two-groups-of-points 英文原文You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2. The cost of the connection betwe…
原文链接: https://leetcode-cn.com/problems/path-with-minimum-effort 英文原文You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are si…
原文链接: https://leetcode-cn.com/problems/determine-whether-matrix-can-be-obtained-by-rotation 英文原文Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or fals…
原文链接: https://leetcode-cn.com/problems/nearest-exit-from-entrance-in-maze 英文原文You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entr…
原文链接: https://leetcode-cn.com/problems/cyclically-rotating-a-grid 英文原文You are given an m x n integer matrix grid, where m and n are both even integers, and an integer k. The matrix is composed of several layers, which is shown in the below image, …
原文链接: https://leetcode-cn.com/problems/find-a-peak-element-ii 英文原文A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom. Given a 0-indexed m x n matrix mat where no t…
原文链接: https://leetcode-cn.com/problems/check-if-move-is-legal 英文原文You are given a 0-indexed 8 x 8 grid board, where board[r][c] represents the cell (r, c) on a game board. On the board, free cells are represented by '.', white cells are represented b…
原文链接: https://leetcode-cn.com/problems/maximum-matrix-sum 英文原文You are given an n x n integer matrix. You can do the following operation any number of times: Choose any two adjacent elements of matrix and multiply each of them by -1. Two elements are …
原文链接: https://leetcode-cn.com/problems/last-day-where-you-can-still-cross 英文原文There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matri…
原文链接: https://leetcode-cn.com/problems/minimize-the-difference-between-target-and-chosen-elements 英文原文You are given an m x n integer matrix mat and an integer target. Choose one integer from each row in the matrix such that the absolute difference be…
原文链接: https://leetcode-cn.com/problems/convert-1d-array-into-2d-array 英文原文You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n column…
原文链接: https://leetcode-cn.com/problems/grid-game 英文原文You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix. Both robots i…
原文链接: https://leetcode-cn.com/problems/check-if-word-can-be-placed-in-crossword 英文原文You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' t…
原文链接: https://leetcode-cn.com/problems/minimum-operations-to-make-a-uni-value-grid 英文原文You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid. A uni-value grid is …
原文链接: https://leetcode-cn.com/problems/minimum-cost-homecoming-of-a-robot-in-a-grid 英文原文There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [s…
原文链接: https://leetcode-cn.com/problems/count-fertile-pyramids-in-a-land 英文原文A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented…
原文链接: https://leetcode-cn.com/problems/rotate-matrix-lcci 英文原文Given an image represented by an N x N matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place? Example 1: Given matrix…
原文链接: https://leetcode-cn.com/problems/zero-matrix-lcci 英文原文Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] …
原文链接: https://leetcode-cn.com/problems/color-fill-lcci 英文原文Implement the "paint fill" function that one might see on many image editing programs. That is, given a screen (represented by a two-dimensional array of colors), a point, and a new color, fi…
原文链接: https://leetcode-cn.com/problems/tic-tac-toe-lcci 英文原文Design an algorithm to figure out if someone has won a game of tic-tac-toe. Input is a string array of size N x N, including characters " ", "X" and "O", where " " represents a empty grid. T…
原文链接: https://leetcode-cn.com/problems/er-wei-shu-zu-zhong-de-cha-zhao-lcof 中文题目在一个 n * m 的二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个高效的函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 示例: 现有矩阵 matrix 如下: [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 2…