LeetCode --- 1030. Matrix Cells in Distance Order 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1030. Matrix Cells in Distance Order 解题报告相关的知识,希望对你有一定的参考价值。

You are given four integers rowcolsrCenter, and cCenter. There is a rows x cols matrix and you are on the cell with the coordinates (rCenter, cCenter).

Return the coordinates of all cells in the matrix, sorted by their distance from (rCenter, cCenter) from the smallest distance to the largest distance. You may return the answer in any order that satisfies this condition.

The distance between two cells (r1, c1) and (r2, c2) is |r1 - r2| + |c1 - c2|.

Example 1:

Input: rows = 1, cols = 2, rCenter = 0, cCenter = 0
Output: [[0,0],[0,1]]
Explanation: The distances from (0, 0) to other cells are: [0,1]

Example 2:

Inp

以上是关于LeetCode --- 1030. Matrix Cells in Distance Order 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode --- 1030. Matrix Cells in Distance Order 解题报告

Leetcode 1030. Matrix Cells in Distance Order

Leetcode-1030 Next Greater Node In Linked List(链表中的下一个更大节点)

[LeetCode] 542. 01 Matrix

LeetCode -- Search a 2D Matrix & Search a 2D Matrix II

LeetCode——Search a 2D Matrix