原文链接: https://leetcode-cn.com/problems/valid-sudoku 英文原文Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must…
标签详情
矩阵 分类
原文链接: https://leetcode-cn.com/problems/sudoku-solver 英文原文Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9 must occur exactly once in each row. Each …
原文链接: https://leetcode-cn.com/problems/rotate-image 英文原文You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). You have to rotate the image in-place, which means you have to modify the input 2D matrix dire…
原文链接: https://leetcode-cn.com/problems/spiral-matrix 英文原文Given an m x n matrix, return all elements of the matrix in spiral order. Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Example 2: Input: matrix = [[1,2,3,4],…
原文链接: https://leetcode-cn.com/problems/spiral-matrix-ii 英文原文Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. Example 1: Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: n = 1 Outp…
原文链接: https://leetcode-cn.com/problems/unique-paths-ii 英文原文A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reac…
原文链接: https://leetcode-cn.com/problems/minimum-path-sum 英文原文Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or …
原文链接: https://leetcode-cn.com/problems/set-matrix-zeroes 英文原文Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix. You must do it in place. Example 1: Input: matrix = [[1,1,1],[1,0,1],[…
原文链接: https://leetcode-cn.com/problems/search-a-2d-matrix 英文原文Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer o…
原文链接: https://leetcode-cn.com/problems/word-search 英文原文Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells ar…
原文链接: https://leetcode-cn.com/problems/maximal-rectangle 英文原文Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1"…
原文链接: https://leetcode-cn.com/problems/surrounded-regions 英文原文Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded r…
原文链接: https://leetcode-cn.com/problems/dungeon-game 英文原文The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x n rooms laid out in a 2D grid. Our valiant knight was initially posit…
原文链接: https://leetcode-cn.com/problems/number-of-islands 英文原文Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacen…
原文链接: https://leetcode-cn.com/problems/word-search-ii 英文原文Given an m x n board of characters and a list of strings words, return all words on the board. Each word must be constructed from letters of sequentially adjacent cells, where adjacent cells a…
原文链接: https://leetcode-cn.com/problems/maximal-square 英文原文Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example 1: Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],[…
原文链接: https://leetcode-cn.com/problems/search-a-2d-matrix-ii 英文原文Write an efficient algorithm that searches for a target value in an m x n integer matrix. The matrix has the following properties: Integers in each row are sorted in ascending from left…
原文链接: https://leetcode-cn.com/problems/game-of-life 英文原文According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." The board is made up of …
原文链接: https://leetcode-cn.com/problems/range-sum-query-2d-immutable 英文原文Given a 2D matrix matrix, handle multiple queries of the following type: Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, …
原文链接: https://leetcode-cn.com/problems/max-sum-of-rectangle-no-larger-than-k 英文原文Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k. It is guaranteed that there will be…
原文链接: https://leetcode-cn.com/problems/kth-smallest-element-in-a-sorted-matrix 英文原文Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest …
原文链接: https://leetcode-cn.com/problems/trapping-rain-water-ii 英文原文Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining. Example 1: Input: heightM…
原文链接: https://leetcode-cn.com/problems/pacific-atlantic-water-flow 英文原文There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touc…
原文链接: https://leetcode-cn.com/problems/battleships-in-a-board 英文原文Given an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board. Battleships can only be placed horizontally or vertically o…
原文链接: https://leetcode-cn.com/problems/diagonal-traverse 英文原文Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. Example 1: Input: mat = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,4,7,5,3,6,8,9] Example 2: Inp…
原文链接: https://leetcode-cn.com/problems/minesweeper 英文原文Let's play the minesweeper game (Wikipedia, online game)! You are given an m x n char matrix board representing the game board where: 'M' represents an unrevealed mine, 'E' represents an unreveal…
原文链接: https://leetcode-cn.com/problems/01-matrix 英文原文Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example 1: Input: mat = [[0,0,0],[0,1,0],[0,0,0]] Output: [[0,0,0…
原文链接: https://leetcode-cn.com/problems/reshape-the-matrix 英文原文In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data. You are given an m x n matrix ma…
原文链接: https://leetcode-cn.com/problems/image-smoother 英文原文An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the …
原文链接: https://leetcode-cn.com/problems/cut-off-trees-for-golf-event 英文原文You are asked to cut off all the trees in a forest for a golf event. The forest is represented as an m x n matrix. In this matrix: 0 means the cell cannot be walked through. 1 re…
1 / 5