Java Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] countOfPairs(int n, int x, int y) {\n        int[][] graph = new int[n + 1][n + 1];\n        for(int[] row : graph){\n            Arrays.fill(row, 1000000);\n        }\n        for(int i = 1; i < n; i++){\n            graph[i][i + 1] = 1;\n            graph[i + 1][i] = 1;\n        }\n        graph[x][y] = 1;\n        graph[y][x] = 1;\n\n        for(int k = 1; k <= n; k++){\n            for(int i = 1; i <= n; i++){\n                for(int j = 1; j <= n; j++){\n                    graph[i][j] = Math.min(graph[i][j], graph[i][k] + graph[k][j]);\n                }\n            }\n        }\n\n        int[] result = new int[n];\n        for(int i = 1; i <= n; i++){\n            for(int j = 1; j <= n; j++){\n                if(i != j){\n                    int path = graph[i][j];\n                    result[path - 1]++;\n                }\n            }\n        }\n        return result;\n    }\n}\n```
['Java']