You are given an array of integers colors, where each element represents a color, and a queries where each query is in the form [i, c].
For each query [i, c], find the shortest distance between index i and any index colors[j] == c. The distance between index i and index c does not exist in colors, the answer for that query is
Return an array of integers representing the answers to all queries in the given order.
Constraints:
colors.length
colors[i]
queries.length
queries[i].length
queries[i][0] colors.length
queries[i][1]
You are given an array of integers colors, where each element represents a color, and a queries where each query is in the form [i, c].
For each query [i, c], find the shortest distance between index i and any index colors[j] == c. The distance between index i and index c does not exist in colors, the answer for that query is
Return an array of integers representing the answers to all queries in the given order.
Constraints:
colors.length
colors[i]
queries.length
queries[i].length
queries[i][0] colors.length
queries[i][1]