Very Easy C++ Problem: Just Needed One Night to Understand 
Code


# Code
```cpp []
#define P pair<int,int>
const int MOD = 1e9+7;

class Solution 
{
    vector<vector<int>> paths;
    vector<int> dist;

    int dfs(vector<vector<P>>& adj, int current_node, vector<int>& visited, int& n, vector<int>& current_path , vector<int>& dp)
    {
       // visited[current_node] = 1;
        if(current_node == n)
        {
            return 1;
        }

        if(dp[current_node] != -1)
        {
            return dp[current_node];
        }

        int meow = 0;

        for(auto it : adj[current_node])
        {
            if(!visited[it.second] && dist[it.second] < dist[current_node])
            {
                current_path.push_back(it.second);
                meow = (meow + dfs(adj , it.second , visited , n , current_path , dp)) % MOD;
                current_path.pop_back();
            }
        }

        //visited[current_node] = 0;

        return dp[current_node] = meow;
    }

public:
    int countRestrictedPaths(int n, vector<vector<int>>& edges) 
    {
        vector<vector<P>> adj(n+1);  

        for(auto it : edges)
        {
            int u = it[0];
            int v = it[1];
            int wt = it[2];
            adj[u].push_back({wt, v});
            adj[v].push_back({wt, u});
        }

        dist = vector<int>(n+1, INT_MAX);
        priority_queue<P, vector<P>, greater<P>> pq;

        dist[n] = 0;
        pq.push({0, n});

        while(!pq.empty())
        {
            auto top = pq.top();
            pq.pop();
            int currDist = top.first;
            int node = top.second;
            
            if(currDist > dist[node]) continue;
            
            for(auto each : adj[node])
            {
                int edgeWt = each.first;
                int neighbor = each.second;
                
                if(currDist + edgeWt < dist[neighbor])
                {
                    dist[neighbor] = currDist + edgeWt;
                    pq.push({dist[neighbor], neighbor});
                }
            }
        }
        
        vector<int> dp(n+1 , -1);

        vector<int> visited(n+1 , 0);
        vector<int> current_path = {1};
        dfs(adj , 1 , visited , n , current_path , dp);

        return dp[1] % MOD;
    }
};

```
['Dynamic Programming', 'Graph', 'Shortest Path', 'C++']