C++ | Simple Solution | Brute Force
We know that maximum seconds we can make through last two digits is 99 so lets try all comibantions from making 0 to 99 and remaining seconds by using minute di
We know that maximum seconds we can make through last two digits is 99 so lets try all comibantions from making 0 to 99 and remaining seconds by using minute digits.\n\nIf you need further clarification please comment it down.\n\n\n```\nclass Solution {\npublic:\n    int getCost(string s,int start,int move,int push)\n    {\n        int c = 0;\n        for(int i=0;i<s.length();i++)\n        {\n            if(i == 0)\n            {\n\t\t\t    // if not the start digit\n                if((s[i] - \'0\') != start)\n                {\n                    c += move;\n                }\n            }\n            else\n            {\n\t\t\t\t// if digit is not same as prev then we need to move\n                if(s[i] != s[i-1])\n                {\n                    c += move;\n                }\n            }\n            c += push;\n        }\n        return c;\n    }\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        \n        int ans = 100000000;\n        for(int i=0;i<100;i++)\n        {\n            if(targetSeconds < i)\n                break;\n\n            int x = targetSeconds - i;\n\n            if(x % 60 == 0)\n            {\n\n                string s;\n                if(i < 10)\n                {\n                    s += "0";\n                }\n                s += to_string(i);\n\n\n                int m = x / 60;\n\t\t\t\t// minute digits cannot exceed 2\n                if(m >= 100)\n                    continue;\n                if(m > 0){\n                    s = to_string(m) + s;\n                    ans = min(ans,getCost(s,startAt, moveCost, pushCost));\n                }\n                else\n                {\n                    if(i < 10)\n                    {\n                        ans = min(ans,getCost(to_string(i),startAt, moveCost, pushCost));\n                    }\n                    else\n                    {\n                        ans = min(ans,getCost(s,startAt, moveCost, pushCost));\n                    }\n                }\n                \n                \n            }\n        }\n\n        return ans;\n\n\n    }\n};
[]