simple Floyd-Warshall algorithm 🤩🤩
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    vector<int> countOfPairs(int n, int x, int y) {
        vector<vector<int>>matrix(n+1,vector<int>(n+1,1e9));
        for(int i=1;i<n;i++){
            matrix[i][i+1]=1;
            matrix[i+1][i]=1;
        }
        matrix[x][y]=1;
         matrix[y][x]=1;

         for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i==j)matrix[i][j]=0;
            }
         }

         for(int via=1;via<=n;via++){

           for(int i=1;i<=n;i++){
                for(int j=1;j<=n;j++){
                    matrix[i][j]=min(matrix[i][j],matrix[i][via]+matrix[via][j]);
                }
            }
        }

        vector<int>ans(n);
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i==j) continue;
                int value=matrix[i][j];

                ans[value-1]++;
            }
        }

        return ans;
    }
};
```
['C++']