Simple C++ solution
Code\n\nclass Solution {\npublic:\n    int countPaths(int n, vector<vector<int>>& roads) {\n        vector<pair<int, int>> adj[n];\n        \n        for(auto i
# Code\n```\nclass Solution {\npublic:\n    int countPaths(int n, vector<vector<int>>& roads) {\n        vector<pair<int, int>> adj[n];\n        \n        for(auto it : roads)\n        {\n            adj[it[0]].push_back({it[1], it[2]});\n            adj[it[1]].push_back({it[0], it[2]});\n        }\n        \n        priority_queue<pair<long long, int>, vector<pair<long long, int>>,\n        greater<pair<long long, int>>> pq;\n        vector<long long> dist(n, 1e18);\n        vector<long long> ways(n, 0);\n        dist[0] = 0;\n        ways[0] = 1;\n        pq.push({0, 0});\n        int mod = (1e9 + 7);\n        \n        while(!pq.empty())\n        {\n            long long dis = pq.top().first;\n            int node = pq.top().second;\n            pq.pop();\n            \n            for(auto it : adj[node])\n            {\n                long long edgeWeight = it.second;\n                int adjNode = it.first;\n                \n                if(dis + edgeWeight < dist[adjNode])\n                {\n                    dist[adjNode] = dis + edgeWeight;\n                    pq.push({dist[adjNode], adjNode});\n                    ways[adjNode] = ways[node];\n                }\n                else if(dis + edgeWeight == dist[adjNode])\n                {\n                    ways[adjNode] = (ways[adjNode] + ways[node]) % mod;\n                }\n            }\n        }\n        return ways[n - 1] % mod;\n    }\n};\n```
['C++']