Easy C++ Solution | | C++
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 {\npublic:\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector<vector<int>> edges;\n        for(int i=0;i<n-1;i++) edges.push_back({i, i+1});\n        edges.push_back({x-1, y-1});\n        \n        vector<vector<int>> dist(n, vector<int>(n, 1e9));\n        for(auto it: edges) {\n            dist[it[0]][it[1]]=1;\n            dist[it[1]][it[0]]=1;\n        }\n        for(int i=0;i<n;i++) dist[i][i] = 0;\n\n         for(int k=0;k<n;k++){ // i -> j via k\n            for(int i=0;i<n;i++) {\n                for(int j=0;j<n;j++) {\n                    // if(dist[i][k] == INT_MAX or dist[k][j] == INT_MAX) continue;\n                    dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);\n                }\n            }\n        }\n        vector<int> ans;\n        for(int k=1;k<=n;k++) {\n            int count = 0;\n            for(int i=0;i<n;i++) {\n                for(int j=0;j<n;j++) {\n                    if(dist[i][j] == k) count++;\n                }   \n            }\n            ans.push_back(count);\n        }\n        return ans;\n    }\n};\n```
['C++']