✅ C++ | All Combination | Brute Force | Easy | Readable
\nclass Solution {\npublic:\n    //finding answer of every possible minute that equal to targetSecond\n    int solve(vector<int> &a,int sa, int mc, int pc){\n  
```\nclass Solution {\npublic:\n    //finding answer of every possible minute that equal to targetSecond\n    int solve(vector<int> &a,int sa, int mc, int pc){\n        int ans = 0;\n        if(a[0] != sa){\n            ans += mc;\n        }\n        ans += pc;\n        for(int i=1;i<a.size();i++){\n            if(a[i] != a[i-1]){\n                ans += mc;\n            }\n            ans += pc;\n            \n        }\n        return ans;\n    }\n    \n    int minCostSetTime(int sa, int mc, int pc, int ts) {\n        int cost = 1e8;\n        //trying all permutation\n        for(int i=0;i<=9;i++){\n            for(int j=0;j<=9;j++){\n                int min = i*10+j; // minutes\n                for(int k=0;k<=9;k++){\n                    for(int l=0;l<=9;l++){\n\t\t\t\t\t    int sec = k*10 + l;//seconds\n                        vector<int> ans;\n                        int m = min*60 + sec; \n                        if(m == ts){\n                            ans.emplace_back(i);\n                            ans.emplace_back(j);\n                            ans.emplace_back(k);\n                            ans.emplace_back(l);\n                            cost = min(cost,solve(ans,sa,mc,pc));\n                             while(ans[0] == 0){\n                                 ans.erase(ans.begin());\n                                 cost = min(cost,solve(ans,sa,mc,pc));\n                             }\n                        }\n                    }\n                }\n            }\n        }\n        return cost;\n    }\n};\n```
['C']