3488. Closest Equal Element Queries
You are given a circular array
nums
and an arrayqueries
.For each query
i
, you have to find the following:
- The minimum distance between the element at index
queries[i]
and any other indexj
in the circular array, wherenums[j] == nums[queries[i]]
. If no such index exists, the answer for that query should be -1.Return an array
answer
of the same size asqueries
, whereanswer[i]
represents the result for queryi
.
go
1 | package main |