Append the array to itself python O(N) solution. 
IntuitionMost of these circular array problems can be solved by appending or prepending the array upon itself.Once I had that intuition it just became a nearest
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Most of these circular array problems can be solved by appending or prepending the array upon itself.

Once I had that intuition it just became a nearest index with the same number from the right and nearest index with the same number from the left problem. 

You can also solve this using two pointers by doing combined = nums + nums + nums and keeping track of the nearest index coming with number x in a dictionary coming from both sides. 

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

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(N) could me more efficient if i took the modulo rather than doubling the array

# Code
```python3 []
class Solution:
    def solveQueries(self, nums: List[int], queries: List[int]) -> List[int]:
        n = len(nums)
        left = [-1] * n
        mp = {}

        for i, num in enumerate(nums + nums):
            if i >= n:
                left[i - n] = i - mp[num] 
            mp[num] = i
        combos = nums + nums

        mp = {}
        right = [-1] * n
        for i in range(2*n-1, -1, -1):
            num = combos[i]
            if i < n:
                right[i] = mp[num] - i
            mp[num] = i

        res = []

        for i in queries:
            l = left[i]
            r = right[i]

            m = min(l, r)

            res.append(-1 if m >= n else m)

        return res

```
['Python3']