Minimum Cost For Tickets Solution | C++ | Easy
Cost[i] -> total amount spent till day i to travell at all the days before it.\n\n\nclass Solution {\npublic:\n    int mincostTickets(vector<int>& days, vector<
Cost[i] -> total amount spent till day i to travell at all the days before it.\n\n```\nclass Solution {\npublic:\n    int mincostTickets(vector<int>& days, vector<int>& costs) {\n        set<int> dd(days.begin(),days.end());\n        int cost[366];\n        memset(cost,0,sizeof(cost));\n        int one=costs[0],seven=costs[1],thirty=costs[2];\n        for(int i=1;i<=365;i++)\n        {\n            cost[i]=cost[i-1];\n            if(dd.find(i)!=dd.end())\n            {\n                cost[i] = min(cost[i-1>=0?i-1:0]+one,min(seven+cost[i-7>=0?i-7:0],thirty+cost[i-30>=0?i-30:0]));\n            }\n        }\n        \n        return cost[365];\n    }\n};\n```
['Dynamic Programming', 'C']