Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita308079

Browse files
refactor 1030
1 parent716a4f0 commita308079

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

‎src/main/java/com/fishercoder/solutions/_1030.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,8 @@
11
packagecom.fishercoder.solutions;
22

3-
importjava.util.ArrayList;
43
importjava.util.LinkedList;
5-
importjava.util.List;
64
importjava.util.Queue;
75

8-
/**
9-
* 1030. Matrix Cells in Distance Order
10-
*
11-
* We are given a matrix with R rows and C columns has cells with integer coordinates (r, c), where 0 <= r < R and 0 <= c < C.
12-
*
13-
* Additionally, we are given a cell in that matrix with coordinates (r0, c0).
14-
*
15-
* Return the coordinates of all cells in the matrix, sorted by their distance from (r0, c0) from smallest distance to largest distance. Here, the distance between two cells (r1, c1) and (r2, c2) is the Manhattan distance, |r1 - r2| + |c1 - c2|. (You may return the answer in any order that satisfies this condition.)
16-
*
17-
* Example 1:
18-
* Input: R = 1, C = 2, r0 = 0, c0 = 0
19-
* Output: [[0,0],[0,1]]
20-
* Explanation: The distances from (r0, c0) to other cells are: [0,1]
21-
*
22-
* Example 2:
23-
* Input: R = 2, C = 2, r0 = 0, c0 = 1
24-
* Output: [[0,1],[0,0],[1,1],[1,0]]
25-
* Explanation: The distances from (r0, c0) to other cells are: [0,1,1,2]
26-
* The answer [[0,1],[1,1],[0,0],[1,0]] would also be accepted as correct.
27-
*
28-
* Example 3:
29-
* Input: R = 2, C = 3, r0 = 1, c0 = 2
30-
* Output: [[1,2],[0,2],[1,1],[0,1],[1,0],[0,0]]
31-
* Explanation: The distances from (r0, c0) to other cells are: [0,1,1,2,2,3]
32-
* There are other answers that would also be accepted as correct, such as [[1,2],[1,1],[0,2],[1,0],[0,1],[0,0]].
33-
*
34-
* Note:
35-
*
36-
* 1 <= R <= 100
37-
* 1 <= C <= 100
38-
* 0 <= r0 < R
39-
* 0 <= c0 < C
40-
* */
416
publicclass_1030 {
427
publicstaticclassSolution1 {
438
publicint[][]allCellsDistOrder(intR,intC,intr0,intc0) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp