Easy and Simple C++ Solution
Code\n\nclass Solution {\nprivate:\n    void dfs(int src, int dest, vector<int> adj[], vector<vector<int>> &dis, int d) {\n\n        dis[src][dest] = d;\n      
# Code\n```\nclass Solution {\nprivate:\n    void dfs(int src, int dest, vector<int> adj[], vector<vector<int>> &dis, int d) {\n\n        dis[src][dest] = d;\n        dis[dest][src] = d;\n\n        for(auto it : adj[src]) {\n            if(dis[it][dest] >= d+1) {\n                dfs(it, dest, adj, dis, d+1);\n            }\n        }\n    }\n\npublic:\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector<int> adj[n+1];\n        for(int i = 1; i < n; i++) {\n            adj[i].push_back(i+1);\n            adj[i+1].push_back(i);\n        }\n        adj[x].push_back(y);\n        adj[y].push_back(x);\n\n        vector<vector<int>> dis(n+1, vector<int>(n+1, INT_MAX));\n\n        for(int i = 1; i <= n; i++) {\n            dfs(i, i, adj, dis, 0);\n        }\n\n        vector<int> ans(n, 0);\n        for(int i = 1; i <= n; i++) {\n            for(int j = 1; j <= n; j++) {\n                if(dis[i][j] == 0)\n                    continue;\n                ans[dis[i][j]-1]++;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']