Available question text
Given an array of colored values and multiple queries (index, target color), return for each query the minimum absolute distance from the index to any element of that color, or -1 if it doesn't exist. The challenge is to handle many queries efficiently by preprocessing the positions of each color so you can quickly find the nearest occurrence per query.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 1182. Shortest Distance to Target Color
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source