C++ || 100% fast || Looks Lengthy but easy to Understand ||
\tclass Solution {\n\tpublic:\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        int min1=targetSeconds/60;\n       
\tclass Solution {\n\tpublic:\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        int min1=targetSeconds/60;\n        int sec1=targetSeconds%60;\n        int min2=min1-1;\n        int sec2=targetSeconds-(min2*60);\n        //cout<<min1<<sec1<<" "<<min2<<sec2;\n        string str1="0000";\n        int i=1;\n        if(sec1<=99 && min1<=99){\n            while(min1){\n                int val=min1%10;\n                str1[i--]=val+\'0\';\n                min1/=10;\n            }\n             i=3;\n            while(sec1){\n                int val=sec1%10;\n                str1[i--]=val+\'0\';\n                sec1/=10;\n            }\n        }\n        \n        \n        string str2="0000";\n        if(sec2 <= 99 && min2<=99){\n                int i=1;\n            while(min2){\n                int val=min2%10;\n                str2[i--]=val+\'0\';\n                min2/=10;\n            }\n             i=3;\n            while(sec2){\n                int val=sec2%10;\n                str2[i--]=val+\'0\';\n                sec2/=10;\n            }\n        }\n        //cout<<str1<<" "<<str2<<endl;\n        \n        \n        //cost for str1\n        int flag=0;\n        i=0;\n        char sa=startAt+\'0\';\n        long cost1=0;\n        while(i<str1.size()){\n            if(flag==0 && str1[i]==\'0\'){\n                i++;continue;\n            }else{\n                flag=1;\n                if(sa!=str1[i]){\n                    cost1+=(moveCost+pushCost);\n                    sa=str1[i];\n                }else\n                    cost1+=pushCost;\n                \n                i++;\n            }\n            \n        }\n        \n        //cost for str2\n        flag=0;\n        i=0;\n        sa=startAt+\'0\';\n        long cost2=0;\n         while(i<str2.size()){\n            if(flag==0 && str2[i]==\'0\'){\n                i++;continue;\n            }else{\n                flag=1;\n                if(sa!=str2[i]){\n                    cost2+=(moveCost+pushCost);\n                    sa=str2[i];\n                }else\n                    cost2+=pushCost;\n                \n                i++;\n            }\n            \n        }\n        //cout<<cost1<<" "<<cost2<<endl;\n        if(cost1==0)return cost2;\n        if(cost2==0)return cost1;\n        return min(cost1,cost2);\n    }\n\t};
[]