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

Commitfa29e41

Browse files
refactor 1182
1 parent0c5a8ea commitfa29e41

File tree

1 file changed

+0
-28
lines changed

1 file changed

+0
-28
lines changed

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,6 @@
55
importjava.util.List;
66
importjava.util.Map;
77

8-
/**
9-
* 1182. Shortest Distance to Target Color
10-
*
11-
* You are given an array colors, in which there are three colors: 1, 2 and 3.
12-
* You are also given some queries. Each query consists of two integers i and c,
13-
* return the shortest distance between the given index i and the target color c. If there is no solution return -1.
14-
*
15-
* Example 1:
16-
* Input: colors = [1,1,2,1,3,2,2,3,3], queries = [[1,3],[2,2],[6,1]]
17-
* Output: [3,0,3]
18-
* Explanation:
19-
* The nearest 3 from index 1 is at index 4 (3 steps away).
20-
* The nearest 2 from index 2 is at index 2 itself (0 steps away).
21-
* The nearest 1 from index 6 is at index 3 (3 steps away).
22-
*
23-
* Example 2:
24-
* Input: colors = [1,2], queries = [[0,3]]
25-
* Output: [-1]
26-
* Explanation: There is no 3 in the array.
27-
*
28-
* Constraints:
29-
* 1 <= colors.length <= 5*10^4
30-
* 1 <= colors[i] <= 3
31-
* 1 <= queries.length <= 5*10^4
32-
* queries[i].length == 2
33-
* 0 <= queries[i][0] < colors.length
34-
* 1 <= queries[i][1] <= 3
35-
* */
368
publicclass_1182 {
379
publicstaticclassSolution1 {
3810
publicList<Integer>shortestDistanceColor(int[]colors,int[][]queries) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp