Easy Solution try once...
IntuitionApproachComplexity
Time complexity:

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

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

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

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

# Code
```java []
class Solution {
    public List<Integer> solveQueries(int[] nums, int[] queries) {
        List<Integer> arr=new ArrayList<>();
        int n=nums.length;
        for(int i=0;i<3*n;i++){
            arr.add(nums[i%n]);
        }
        HashMap<Integer,Integer> mp=new HashMap<>();
        List<Integer> l=new ArrayList<>();
         List<Integer> r=new ArrayList<>();
        for(int i=0;i<arr.size();i++){
             int num=arr.get(i);
            if(!mp.containsKey(num)){
                mp.put(num,i);
                l.add(-1);
            }else{
              int previdx=mp.get(num);
              int curridx=i;
              l.add(curridx-previdx);
              mp.put(num,curridx);
            }

        }

        mp.clear();
        for(int i=arr.size()-1;i>=0;i--){
            int num=arr.get(i);
            if(!mp.containsKey(num)){
                mp.put(num,i);
                r.add(-1);
            }else{
              int nextidx=mp.get(num);
              int curridx=i;
              r.add(nextidx-curridx);
              mp.put(num,curridx);
            }
        }
    
        List<Integer> ans=new ArrayList<>();
        Collections.reverse(r);
        for(int i=0;i<queries.length;i++){
            int idx=queries[i]+n;
            if(l.get(idx)==nums.length || r.get(idx)==nums.length){
              ans.add(-1);
            }else if(l.get(idx)==-1 && r.get(idx)==-1){
              ans.add(-1);
            }
            else{
               if(l.get(idx)==-1){
                 ans.add(r.get(idx));
               }else if(r.get(idx)==-1){
                ans.add(l.get(idx));
               }else{
                 ans.add(Math.min(l.get(idx),r.get(idx)));
               }
            }
        }

        return ans;
    }
}
```
['Array', 'Hash Table', 'Java']