Floydd Warshall implementation
Intuition\n Describe your first thoughts on how to solve this problem. \nMulti source shortest path. \nConstraint is also small.\n\n# Approach\n Describe your a
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMulti source shortest path. \nConstraint is also small.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFloydd Warshall.\n\n# Complexity\n- Time complexity:O(N^3)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N^2)\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>> grid(n+1,vector<int>(n+1,1e9));\n\n        // i <-> i+1\n        for(int i=1;i<n;i++){\n            grid[i][i+1] = 1;\n            grid[i+1][i] = 1;\n        }\n        // x <-> y\n        grid[x][y] =1;\n        grid[y][x] = 1;\n\n        //floyd warshall\n\n        for(int via = 1;via<=n; via++){\n\n            for(int i=1;i<=n;i++){\n                for(int j=1;j<=n;j++){\n                    if(i==j) grid[i][j]=0;\n                    else \n                        grid[i][j] = min(grid[i][j],grid[i][via]+grid[via][j]);\n                }\n            }\n\n        }\n\n        vector<int> ans(n,0);\n\n        for(int i=1;i<=n;i++){\n            for(int j=1;j<=n;j++){\n                if(i==j) continue;\n                int val = grid[i][j];\n                ans[val-1]++;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']