C++ || Brute Force Solution with Detailed Explanation
The main aim of the solution is to generate all possible ways to generate the required time, and then calculating the cost of each of them while returning the m
The main aim of the solution is to generate all possible ways to generate the required time, and then calculating the cost of each of them while returning the minimum one. \n\n***Note***: I am not actually generating all the possible outcomes, like for target as 600second, when taken as 9 mins 60 second, the possible buttons to be pushed can be *"0960"* and *"960"*. But I am not generating *"0960"* as it will require pushing an extra button which will obviously increase the cost, so no point in considering it. \n\n**Explaination of Code** \nSection 1:\nHere the target seconds are reduced till they are 2 digits or less, if they are of 3 digits or more, they can not be put in the timer as only 2 digits are allowed in microwave for seconds. \nEg: for 600 seconds will reduced to 9 mins, 60 second, (mins = 9, tar = 60)\n\nSection 2:\nHere I am generating different ways of pushing buttons in form of string by reducing seconds(*tar*) and increasing minutes(*mins*)\nEg: "960" is pushed as a possible string in vector *ways*, mins = 10, and tar = 0, which leads to exiting the loop\n\nSection 3:\nSection 2 ends when seconds are less than 60(*tar<60*), So now, if there is a possible way(mins < 100) that can be consi, I am storing it in the *ways* vector\nEg: "1000" is pushed as a possible string in vector *ways*\n\nSection 4:\nFor all possible ways(strings in *ways*) we calculate the cost, and then return the minimum one\n```\nclass Solution {\npublic:\n    int minCostSetTime(int start, int move, int push, int tar) {\n        vector<string> ways;\n        int mins = 0; \n\t\t\n\t\t//Section 1\n        while(tar >= 100)\n        {\n            mins++;\n            tar -= 60;\n        }\n        string s = "";\n        \n\t\t\n\t\t//Section 2\n        while(tar >= 60)\n        {\n            s = "";\n            if(mins != 0)\n                s += to_string(mins);\n            s += to_string(tar);\n            ways.push_back(s);\n            tar -= 60;\n            mins++;\n        }\n        \n\t\t//Section 3\n        s = "";\n        if(mins >= 100)\n            goto section4;\n        if(mins != 0)\n            s += to_string(mins);\n        if(tar >= 10)\n            s += to_string(tar);\n        else if(tar>0 and tar < 10)\n        {\n            if(mins != 0)\n                s += "0" + to_string(tar);\n            else s += to_string(tar);\n        }\n        else if(tar == 0)\n            s += "00";\n        ways.push_back(s);\n        \n\t\t\n\t\t//Section 4\n        section4:\n        int ans = INT_MAX; \n        for(auto s : ways)\n        {\n            //cout<<s<<" ";\n            int len = s.size(); \n            int sub = 0; \n            char cur = to_string(start)[0];\n            for(int i =0; i<len; i++)\n            {\n                if(cur != s[i])\n                {\n                    sub += move;\n                    cur = s[i];\n                }\n                sub += push;\n            }\n            //cout<<sub<<endl;\n            ans = min(ans, sub);\n        }\n        \n        return ans; \n        \n    }\n};\n```
['C']