java_solution
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 int[] countOfPairs(int n, int x, int y) {
        HashMap<Integer,ArrayList<pair>>map=new HashMap<>();

        for(int i=1;i<=n-1;i++){
            map.putIfAbsent(i,new ArrayList<>());
            map.putIfAbsent(i+1,new ArrayList<>());
            map.get(i).add(new pair(i+1,1));
            map.get(i+1).add(new pair(i,1));

        }
        map.putIfAbsent(x,new ArrayList<>());
        map.putIfAbsent(y,new ArrayList<>());
        map.get(x).add(new pair(y,1));
        map.get(y).add(new pair(x,1));
        int arr[][]=new int[n+1][n+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                arr[i][j]=Integer.MAX_VALUE;
            }
        }
        for(int i=1;i<=n;i++){
            dijkstra(i,map,arr[i]);
        }
        int res[]=new int[n];
        for(int i=1;i<=n;i++){
            
            for(int j=i;j<=n;j++){
                int t=arr[i][j];
                if(t==Integer.MAX_VALUE || t==0){
                    continue;
                }
                int id=t-1;
                res[id]++;
            }
        }
        for(int i=0;i<n;i++){
            res[i]=res[i]*2;
        }
        return res;
    }
    void dijkstra(int node,HashMap<Integer,ArrayList<pair>>map,int arr[]){
        arr[node]=0;
        PriorityQueue<pair>q=new PriorityQueue<>((a,b)->a.wt-b.wt);
        q.add(new pair(node,0));

        while(!q.isEmpty()){
            pair curr=q.poll();
            int wt=curr.wt;
            int currN=curr.node;

            for(pair ngb:map.getOrDefault(currN,new ArrayList<>())){
                int ngbN=ngb.node;
                int ngbWt=ngb.wt;

                if(arr[ngbN]>wt+ngbWt){
                    arr[ngbN]=wt+ngbWt;
                    q.add(new pair(ngbN,wt+ngbWt));
                }
            }
        }
    }
}
class pair{
    int node;
    int wt;
    pair(int n,int w){
        this.node=n;
        this.wt=w;
    }
}
```
['Java']