Simple c++ sol, beats 100%-- all edge cases explained
\n--Just need to take care of edge cases in this problem, problem is easy\n\n\nclass Solution {\npublic:\n    int minCostSetTime(int startAt, int moveCost, int 
\n--Just need to take care of edge cases in this problem, problem is easy\n\n\nclass Solution {\npublic:\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        \n        \n        int cost=INT_MAX, m=targetSeconds/60, n=targetSeconds%60, tc=0, prev=startAt;\n        if(m>=100) m=m-1, n=n+60; \n        \n        int m1=m-1, n1=n+60;\n        vector<int> v1,v2;\n    \n       // cout<<m<<" "<<n<<endl;\n        \n        while(m)\n        {\n            int r=m%10;\n            v1.push_back(r);\n            m/=10;\n        }\n        reverse(v1.begin(), v1.end());\n        \n        while(n)\n        {\n            int r=n%10;\n            v2.push_back(r);\n            n/=10;\n        }\n        \n        if(v1.size()>0 and v2.size()<2)\n        {\n            if(v2.size()==0) \n            {\n                v2.push_back(0);\n                v2.push_back(0);\n            }\n            else v2.push_back(0);\n        }\n        reverse(v2.begin(), v2.end());\n        \n        \n        for(int i=0; i<v2.size(); i++) v1.push_back(v2[i]);\n        \n        \n       // for(int i=0; i<v1.size(); i++) cout<<v1[i]<<" ";   \n        //cout<<endl;\n        \n        for(int i=0; i<v1.size(); i++)\n        {\n            if(v1[i]==prev) tc+=pushCost;\n            else\n            {\n                tc+=moveCost;\n                prev=v1[i];\n                tc+=pushCost;\n            }\n        }\n        cost=min(tc,cost);\n    \n        \n        // cout<<m1<<" "<<n1<<endl;\n        // if we can represent the time by decresing 1 hr and incresing 60 seconds.\n        if(m1>=0 and n1<100)\n        {\n           // cout<<m1<<" "<<n1<<endl;\n            \n            vector<int> v3,v4;\n            while(m1)\n            {\n                int r=m1%10;\n                v3.push_back(r);\n                m1/=10;\n            }\n            reverse(v3.begin(), v3.end());\n        \n            while(n1)\n            {\n                int r=n1%10;\n                v4.push_back(r);\n                n1/=10;\n            }\n            if(v3.size()>0 and v4.size()<2)\n            {\n                if(v4.size()==0) \n                {\n                    v4.push_back(0);\n                    v4.push_back(0);\n                }\n                else v4.push_back(0);\n            }\n            reverse(v4.begin(), v4.end());\n        \n            for(int i=0; i<v2.size(); i++) v3.push_back(v4[i]);\n            \n            //for(int i=0; i<v3.size(); i++) cout<<v3[i]<<" "; \n            \n            tc=0, prev=startAt;\n            for(int i=0; i<v3.size(); i++)\n            {\n                if(v3[i]==prev) tc+=pushCost;\n                else\n                {\n                    tc+=moveCost;\n                    prev=v3[i];\n                    tc+=pushCost;\n                }\n            }   \n            cost=min(tc,cost);\n        }\n        return cost;\n    }\n};
['Array', 'C']