Back to Question
Shortest Distance to Target Color (Preprocessing)
Question Explain
Given an array of colors and a list of queries (index, color), find the shortest distance from the given index to the target color. Preprocessing with maps or arrays is key.
Start Trying This Question Simulation
Click "Start Speaking" and answer the question naturally.