Using Dijkstra Algorithm
IntuitionUse the simplest Dijkstra algorithm traversingApproach
Create Adjancency List which contain pair of node and time
Create Array of cost and time and int
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Use the simplest Dijkstra algorithm traversing

# Approach
<!-- Describe your approach to solving the problem. -->
1. Create Adjancency List which contain pair of node and time
2. Create Array of cost and time and intialize the cost[0] with passingFees[0] and time[0] with 0.
3. Create set of pair of pair of cost ,time and node;
4. Now Follow the Dijkstra Algorithm
5. 

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N+E)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(N+E)

# Code
```cpp []
class Solution {
public:

  


    // void dfsTraversal(map<int,list<pair<int,int>>> &adj,vector<bool> &vis,vector<int>& passingFees,int src,int des,int sumTime,int sumFee,int &maxTime)
    // {
    //   if(src == des)
    //   {
    //      if(maxTime >= sumTime)
    //      {
    //         ans.insert(sumFee);
    //      }
    //      return ;
    //   }

    //   vis[src] = 1;

    //   for(auto neighbour : adj[src])
    //   {
    //     if(!vis[neighbour.first]){
    //        dfsTraversal(adj,vis,passingFees,neighbour.first,des, neighbour.second+sumTime,sumFee + passingFees[neighbour.first],maxTime);
           
    //     }
    //   }

    //   vis[src] = 0;

    // }

    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& passingFees) {
     

        int n = passingFees.size();
        int result = INT_MAX;

        // Creating Adj list
        map<int,list<pair<int,int>>>adj;

        for(int i=0;i<edges.size();i++)
        {
            int u = edges[i][0];
            int v = edges[i][1];
            int t = edges[i][2];

            adj[u].push_back(make_pair(v,t));
            adj[v].push_back(make_pair(u,t));
        }

        vector<int>time(n,INT_MAX);
        vector<int>cost(n,INT_MAX);

        cost[0] = passingFees[0];
        time[0] = 0;

        set<pair<int,pair<int,int>>>st;

        st.insert({cost[0],{0,0}});

        while(!st.empty())
        {
            auto top = *(st.begin());
            st.erase(top);

            int node = top.second.second;

            int nodeCost = top.first;

            int nodeTime = top.second.first;

            if(node == n-1 && nodeTime <= maxTime)
            {
                return result = min(result,nodeCost);
            }

            for(auto i : adj[node])
            {
                int currTime = i.second;
                int currCost = passingFees[i.first];

                if((currTime + nodeTime <= maxTime)&&(currCost + nodeCost <= cost[i.first]))
                {
                    cost[i.first] = currCost + nodeCost;
                    time[i.first] = currTime + nodeTime;

                    st.insert({cost[i.first],{time[i.first],i.first}});
                }
                else if(currTime + nodeTime < time[i.first])
                {
                    time[i.first] = currTime + nodeTime;
                    st.insert({currCost + nodeCost ,{time[i.first],i.first}});
                
                }
            }

        }
        if(result == INT_MAX) return -1;

        return result;

    }
};
```
['Graph', 'C++']