Minimum Cost For Tickets : Dynamic Programming: C++
\nclass Solution {\npublic:\n    int mincostTickets(vector<int>& days, vector<int>& costs) {\n        set<int> dd(days.begin(),days.end());\n        int cost[36
```\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            cost[i] = cost[i-1];\n            if(dd.find(i)!= dd.end()){\n                cost[i] = min(cost[max(0,i-1)]+one, min(cost[max(0,i-7)]+seven, cost[max(0,i-30)]+thirty));\n            }\n        }\n        return cost[365];\n    }\n};\n```
[]