Floyed Warshall algorithm || Easy and simple solution
In question,We clearly see that these talks about Multi-Source path ,So we use Floyed Warshall algorithm\n\nStep 1: Make a grid and fill according to rows and c
**In question,We clearly see that these talks about Multi-Source path ,So we use Floyed Warshall algorithm**\n\nStep 1: Make a grid and fill according to rows and columns .\nStep 2: Apply Floyed Warshall algorithm\nStep 3:  make a result vector\n\n Note: Ensure to dry run the algorithm considering the scenario where i is equal to j,\n                 as it impacts the behavior or results due to self-comparisons.\n\nvector<int> countOfPairs(int n, int x, int y) {\n         vector<vector<int>> grid(n, vector<int>(n,1e3));\n             for(int i=0;i<n;i++){\n            for(int j=0;j<n;j++){\n                // if(i==j) grid[i][j]=0;\n                grid[i][j]=abs(i-j);\n                grid[j][i]=abs(i-j);\n                \n            }\n        }\n\n        grid[x-1][y-1]=1;\n        \n       grid[y-1][x-1]=1;\n        \n        for(int count=0;count<n;count++){\n            \n            for(int r=0;r<n;r++){\n                for(int c=0;c<n;c++){\n                    grid[r][c]=min(grid[r][c],grid[r][count]+grid[count][c]);\n                }\n            }\n        }\n        \n        vector<int> result(n);\n        for(int i = 0; i < n; i++) {\n            for(int j = 0; j < n; j++) {\n\n                if(i != j) {\n                    int val = grid[i][j];\n                    result[val-1]++;\n                }\n\n            }\n        }\n        \n        return result;\n    }\n\t\n\tThanks Everyone .\n\tHappy Coding.
['Graph']