🔥FloydWarshall⚡ || 💯Clean CPP Code✅
\n\n# Complexity\n\n- Time complexity:\nO(n ^ 3)\n\n- Space complexity:\nO(n ^ 2)\n\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n\nclass Solution {\npub
\n\n# Complexity\n```\n- Time complexity:\nO(n ^ 3)\n\n- Space complexity:\nO(n ^ 2)\n```\n\n# Code\n## Please Upvote if it helps\uD83E\uDD17\n```\nclass Solution {\npublic:\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector<int> ans(n);\n        vector<vector<int>> mat(n, vector<int>(n, 1e8));\n        for(int i = 0 ; i < n ; i++){\n            for(int j = 0 ; j < n ; j++){\n                if(j == i + 1)\n                    mat[i][j] = 1, mat[j][i] = 1;\n            }\n        }\n        mat[x - 1][y - 1] = 1;\n        mat[y - 1][x - 1] = 1;\n        \n        for(int k = 0 ; k < n ; k++){\n            for(int i = 0 ; i < n ; i++){\n                for(int j = 0 ; j < n ; j++){\n                    if(i != j && mat[i][k] + mat[k][j] < mat[i][j])\n                        mat[i][j] = mat[i][k] + mat[k][j];\n                }\n            }\n        }\n        for(int i = 0 ; i < n ; i++){\n            for(int j = 0 ; j < n ; j++){\n                if(i != j)\n                    ans[mat[i][j] - 1]++;\n            }\n        }\n        return ans;\n    }\n};\n```
['Graph', 'Matrix', 'C++']