Floyd warshall algo | graph | Easy and small code | c++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: 0(n^3)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:0(n2)\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      // apply floyd warshall \n        vector< vector<int> >dist( n+1, vector<int>(n+1,INT_MAX));\n        for(int i =1; i<=n; i++){\n            dist[i][i] = 0; \n        }\n        for( int i=1; i<n; i++){\n             dist[i][i+1] = 1;\n             dist[i+1][i] = 1;\n        }\n        if(x != y){\n           dist[x][y] =1; \n          dist[y][x] =1;  \n        }\n    \n           for (int k = 1; k <= n; k++) {\n        \n        for (int i = 1; i <=n; i++) {\n           \n            for (int j = 1; j <=n; j++) {\n             \n                if (dist[i][k] != INT_MAX && dist[k][j] != INT_MAX && dist[i][k] + dist[k][j] < dist[i][j]) {\n                    dist[i][j] = dist[i][k] + dist[k][j];\n                }\n            }\n        }\n    }\n     \n    vector<int>counter(n , 0);\n        for( auto it : dist ){\n             for( auto ele : it){\n                 if(ele != INT_MAX and ele != 0 ){\n                 counter[ele-1]++; \n                 }\n             }\n            \n        }\n        return counter; \n        \n    }\n};\n```
['C++']