Back to Questions

Shortest Distance to Target Color (Preprocessing)

96.6K viewsAsked at LinkedIn
Medium

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

Practice answering orally or with text to get instant AI feedback.

Practice with This Question