✅Simple Dijkstra with couting
\n\n# Code\n\nclass Solution {\npublic:\n     vector <int> dijkstra(vector<int>adj[], int S,int n)\n    {\n        set<pair<int,int>> st; \n        vector<int> 
\n\n# Code\n```\nclass Solution {\npublic:\n     vector <int> dijkstra(vector<int>adj[], int S,int n)\n    {\n        set<pair<int,int>> st; \n        vector<int> dist(n+1, 1e9); \n        st.insert({0, S}); \n        dist[S] = 0;\n        while(!st.empty()) {\n            auto it = *(st.begin()); \n            int node = it.second; \n            int dis = it.first; \n            st.erase(it); \n            for(auto it : adj[node]) {\n                int adjNode = it; \n                int edgW = 1; \n                \n                if(dis + edgW < dist[adjNode]) {\n                    if(dist[adjNode] != 1e9) \n                        st.erase({dist[adjNode], adjNode}); \n                    dist[adjNode] = dis + edgW; \n                    st.insert({dist[adjNode], adjNode}); \n                 }\n            }\n        }\n        return dist; \n    }\n    vector<int> countOfPairs(int n, int x, int y) {\n        vector<int>g[n+1];\n        g[1].push_back(2);\n        for(int i=2;i<n;i++){\n            g[i].push_back(i+1);\n            g[i].push_back(i-1);\n        }\n        g[n].push_back(n-1);\n        g[x].push_back(y);\n        g[y].push_back(x);\n        vector<int>dist[n+1];\n        for(int i=1;i<=n;i++){\n            dist[i]=dijkstra(g,i,n);\n        }\n        int cnt=0;\n        vector<int>ans(n,0);\n        for(int k=1;k<=n;k++){\n            int cnt=0;\n            for(int i=1;i<=n;i++){\n                for(int j=i+1;j<=n;j++){\n                  if(dist[i][j]==k){\n                      cnt+=2;\n                  }\n               }\n            }\n            ans[k-1]=cnt;\n        }\n        return ans;\n    }\n};\n```
['Graph', 'C++']