Floyed Warshall algorithm|| Simple & easy solution
just do what it says :)\nprepare graph based on the given connection edge connection information \nhere we will be using 0 based node indexing for easy of calcu
just do what it says :)\nprepare graph based on the given connection edge connection information \nhere we will be using 0 based node indexing for easy of calculation\n\nso once we are ready with ```adjucency matrix ```\nwhat we are asked is count the no of paths which have length 1, 2, 3, ....... n \nand return a n sized vector of count of such path lengths\nso here we need all possible paths as we need counting and one big hint is order of n is just 100 means we can use ```Floyed Warshall algorithm```  to find all pair of paths.\n\nApply Floyed warshall get all pair paths and then just count it out and return the vector\n\n```\nTIME : O(n^3)\nSPACE : O(n^2)\n```\n\n```\nclass Solution {\npublic:\n    \n    vector<int> solve(vector<vector<int>>&m)\n\t{\n\t    int n=m.size();\n\t    for(auto &i: m)\n\t    {\n\t        for(auto &j: i) if(j==-1) j=1e8;\n\t    }\n\t    for(int k=0; k<n; k++)\n\t    {\n\t        for(int i=0; i<n; i++)\n\t        {\n\t            for(int j=0; j<n; j++)\n\t            {\n\t               m[i][j]=min(m[i][j],m[i][k]+m[k][j]);\n\t            }\n\t        }\n\t    }\n\t    \n\t    map<int,int> mp;\n        for(auto i: m)\n        {\n            for(auto j:i)\n            {\n                if(j<100) mp[j]++;\n            }\n        }\n        vector<int> ans(n,0);\n        \n        for(auto i: mp)\n        {\n            if(i.first!=0)\n            ans[i.first-1]=i.second;\n        }\n        return ans;\n        \n\t    // Code here\n\t}\n    vector<int> countOfPairs(int n, int x, int y) \n    {\n        x--;\n        y--;\n        vector<vector<int>> g(n, vector<int>(n,1e3));\n        \n        for(int i=0; i<n; i++)\n        {\n            g[i][i]=0;\n            if(i+1<n)\n            {\n                g[i][i+1]=1;\n                g[i+1][i]=1;\n            }\n        }\n        if(x!=y)\n        {\n            g[x][y]=1;\n            g[y][x]=1;\n        }//now matrix is ready\n\t\t\n\t\t\n        return solve(g);\n        \n        \n        \n        \n        \n    }\n};\n\n```
['C']