C ++ BFS solution
Intuition\nDo a BFS traversal from every house to every other houses.\n Describe your first thoughts on how to solve this problem. \n\n# Complexity\n- Time comp
# Intuition\nDo a BFS traversal from every house to every other houses.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Complexity\n- Time complexity: $$O(N * (V + E))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(N * N + E)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    void bfs(int ind, vector<vector<int>>&dist, vector<vector<int>>&adj){\n        queue<pair<int,int>>q;\n        vector<bool> visited(dist.size(), false); \n        q.push({ind, 0});\n        while(!q.empty()){\n            int node = q.front().first;\n            int value = q.front().second;\n            q.pop();\n            if(dist[ind][node] > value){\n                dist[ind][node] = value;\n            }\n            for(auto it : adj[node]){\n                if (!visited[it]) { \n                    q.push({it, value + 1});\n                    visited[it] = true;\n                }\n            }\n        }\n        return ;\n    }\n\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector<vector<int>>dist(n + 1, vector<int>(n + 1, 1e9));\n        vector<vector<int>>adj(n + 1, vector<int>());\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        for(int i = 1; i <= n; i ++){\n            bfs(i, dist, adj);\n        }\n        vector<int>ans;\n        for(int k = 1; k <= n; k ++){\n            int cnt = 0;\n            for(auto i : dist){\n                for(auto j : i){\n                    if(j == k){\n                        cnt ++;\n                    }\n                }\n            }\n            ans.push_back(cnt);\n        }\n        return ans;\n    }\n};\n\n```
['C++']