it's Work!
IntuitionApproachComplexity
Time complexity:  O(N + Q)

Space complexity: O(N)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:  O(N + Q)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def solveQueries(self, nums: List[int], queries: List[int]) -> List[int]:
        n = len(nums)
        numToListOfindices = defaultdict(list)

        for i, num in enumerate(nums):
            numToListOfindices[num].append(i)
        
        for arr in numToListOfindices.values():
            m = len(arr)
            if m == 1:
                nums[arr[0]] = -1
                continue
            
            for i in range(m):
                curr_element_idx = arr[i]
                nxt = (i + 1) % m
                prev = (i - 1) % m
                next_Same_element_idx = arr[nxt]
                prev__Same_element_idx = arr[prev]
                forward_dist = min((n - curr_element_idx - 1) + next_Same_element_idx + 1, abs(curr_element_idx - next_Same_element_idx)) 
                backward_dist = min(n + curr_element_idx - prev__Same_element_idx, abs(prev__Same_element_idx - curr_element_idx))
                nums[curr_element_idx] = min(forward_dist, backward_dist)

        for i in range(len(queries)):
            queries[i] = nums[queries[i]]
            
        return queries
```
['Hash Table', 'Python3']