Skip to content

Commit a308079

Browse files
refactor 1030
1 parent 716a4f0 commit a308079

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

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

-35
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,8 @@
11
package com.fishercoder.solutions;
22

3-
import java.util.ArrayList;
43
import java.util.LinkedList;
5-
import java.util.List;
64
import java.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
public class _1030 {
427
public static class Solution1 {
438
public int[][] allCellsDistOrder(int R, int C, int r0, int c0) {

0 commit comments

Comments
 (0)