Why simple DFS isn't working?
I have a simple DFS code. Why isn\'t it working.\n\nIt is saying Wrong Answer.\n\n\nclass Solution {\npublic:\n    int ans = INT_MAX, n, t;\n    void dfs(vector
I have a simple DFS code. Why isn\'t it working.\n\nIt is saying Wrong Answer.\n\n```\nclass Solution {\npublic:\n    int ans = INT_MAX, n, t;\n    void dfs(vector<vector<pair<int, int>>>& graph, vector<int>& vis, int curr, int time, int total, vector<int>& pass){\n     //   cout<<curr<<"->"<<total<<" ";\n      //  total += pass[curr];\n       // if(total > 862) return;\n        if(time > t) return; \n        if(curr == n-1){\n            ans = min(ans, total);\n            return;\n        }\n        \n        vis[curr] = 1;\n        for(pair<int, int> i: graph[curr]){\n            if(vis[i.first] == 2 or vis[i.first] == 1) continue;\n            dfs(graph, vis, i.first, time+i.second, total+pass[i.first], pass);\n       //     cout<<ans<<" ";\n        }\n        vis[curr] = 2;\n         \n    }\n    \n    int minCost(int maxTime, vector<vector<int>>& edges, vector<int>& pass) {\n        ans = INT_MAX;\n        n = pass.size();\n        vector<int> vis(n);\n        //flag = false;\n        t = maxTime;\n        vector<vector<pair<int, int>>> graph(n, vector<pair<int, int>>());\n        for(vector<int> i: edges){\n            graph[i[0]].push_back({i[1], i[2]});\n            graph[i[1]].push_back({i[0], i[2]});\n        }\n        \n        dfs(graph, vis, 0, 0, pass[0], pass);\n        \n        return ans == INT_MAX? -1: ans;\n    }\n};\n```\nAny help will be appriciated :)
[]