C++ || explanation || 100% || 0ms
\n Approach:\n Handle two cases separately :\n case:1 --> targetSeconds<100\n case:2 --> targetSeconds>=100\n\n  find all possible time expressions\n  then chec
\n Approach:\n Handle two cases separately :\n case:1 --> targetSeconds<100\n case:2 --> targetSeconds>=100\n\n  find all possible time expressions\n  then check move and push conditions for each expressions\n  and output minimum of them.\n\n```\nclass Solution {\npublic:\n    int minCostSetTime(int start, int mC, int pC, int tS) {\n        \n         int ans=INT_MAX;\n        if(tS<100)\n        {\n            vector<string> vt;  // all possible time expressions\n            \n            string s= to_string(tS);\n            while(s.size()<=4)\n            {\n                vt.push_back(s);\n                s= "0"+s;\n            }\n            \n            int x= tS/60;\n            int rem= tS%60;\n            if(x!=0)\n            {\n                string p1= to_string(x);\n                string p2= to_string(rem);\n                while(p2.size()!=2)\n                {\n                    p2= "0"+p2;\n                }\n                vt.push_back(p1+p2);\n                if(p1.size()==1) vt.push_back("0"+p1+p2);\n            }\n            \n            int tmp=0;\n            for(int i=0; i<vt.size(); i++)\n            {\n                tmp= start;\n                int cost=0;\n                for(auto ch: vt[i])\n                {\n                    if(tmp!=(ch-\'0\') )  // we have to move + push\n                    {\n                        cost+=(mC+pC);\n                        tmp= (ch-\'0\');\n                    }\n                    else cost+= pC;     // we have to only push\n                }\n                ans= min(ans,cost);\n            }\n            \n        }\n        else  \n        {\n            vector<string> vt;  // all possible time expressions\n            \n            int x= tS/60;\n            int rem= tS%60;\n            if(x==100)      // IMP case take tS=6039---> x=100, rem=39\n            {\n                x--;\n                rem+=60;\n            }\n            \n                string p1= to_string(x);\n                string p2= to_string(rem);\n                while(p2.size()!=2)\n                {\n                    p2= "0"+p2;\n                }\n                vt.push_back(p1+p2);\n                if(p1.size()==1) vt.push_back("0"+p1+p2);\n                \n                if(rem+60 <=99)  //  IMP step \n                {\n                    x--;\n                    rem+= 60;\n                    if(x==0)\n                    {\n                         string tt= to_string(rem);\n                         while(tt.size()<=4)\n                         {\n                           vt.push_back(tt);\n                           tt= "0"+ tt;\n                         }\n                    }\n                    else\n                    {\n                          string g1= to_string(x);\n                          string g2= to_string(rem);\n                         \n                          vt.push_back(g1+g2);\n                          if(g1.size()==1) vt.push_back("0"+g1+g2);\n                    }\n                }\n            \n               \n            int tmp=0;\n            for(int i=0; i<vt.size(); i++)\n            {\n                tmp= start;\n                int cost=0;\n                for(auto ch: vt[i])\n                {\n                    if(tmp!=(ch-\'0\') )\n                    {\n                        cost+=(mC+pC);\n                        tmp= (ch-\'0\');\n                    }\n                    else cost+= pC;\n                }\n                ans= min(ans,cost);\n            }\n        }\n        return ans;\n    }\n};\n```
['Greedy']