Runtime 32 ms [Python3] deep explanation with comments.
we will divide this into parts ok! first part if 0<target<10 and second part 10<target<100 and third part greater than 100.\nFirst Part:\n\t\tThe maximum cost w
we will divide this into parts ok! first part if 0<target<10 and second part 10<target<100 and third part greater than 100.\n**First Part:**\n\t\tThe maximum cost will be let max_cost=1*(moveCost +pushCost) for any case go check by ourself once. So if  startAt==targetseconds means we are not making move cost so we return max_cost -moveCost else return max_cost.Easy Right.\n\n**Second Part**\n\t\t\tThe maximun cost will be let max_cost=2*(moveCost+pushCost) for any case. We will use\n\t\t\tsome function to return count if recently  pushed is repeated. for example look below  function.For example:let\'s take target=99 and startAt=9 using below function we get q=2 check it by ourself. From q it says that q no of moveCost are additional in max_cost so we remove q*moveCost from max_cost.Easy right.\n\t\t\t![image](https://assets.leetcode.com/users/images/3483970f-31e6-4cfd-90c3-2ab1afd4eaa5_1644083818.9248292.png)\n\n**Third Case:**\n\tGet the maximum and minimun minutes from below code as show i=max and j=min:\n\t![image](https://assets.leetcode.com/users/images/2b21e808-50c5-4c88-9313-b2ecc5d7b69e_1644083910.1455026.png)\n\n**Case 1: j<10**\n\t\t\t\t\t\tHere maximum cost is 3*(moveCost+pushCost) check it by ourself. It same as second part here we are going to run loop for k in range( j , min(i,9)+1) # we are only considering 0<k<10#.\n\t\t\t\t\t\tHere k=mins and to get remaining seconds h=abs(targetSeconds-(k*60)) and finally update h with str(k)+str(h)#mins+seconds# and remaining is same as second part except we need to \nupdate self.z=startAt to compare new k.\n**Case 2:i>=10:**\n\t\t\t\t\t\t\tHere max_cost=4*(move_Cost+push_Cost) and same as case 1 but for loop range(max(10,j),i+1)# i should be greater than 9#\n\n```class Solution:\n    def minCostSetTime(self, startAt: int, moveCost: int, pushCost: int, targetSeconds: int) -> int:\n        #fun to find count of previous push\n        def leng(t):\n            q=0\n            if t==self.z:\n                q+=1\n            return q\n        self.z=startAt\n        #i=max of minutes\n        i=targetSeconds//60\n        if i>99:\n            i=int(99)\n        #j=min of minutes\n        j=math.ceil((targetSeconds-99)/60)\n        if j<0:\n            j=0\n        #return value mi\n        mi=float(inf)\n        #first part\n        if targetSeconds<10:\n            #max cost\n            m=1*(moveCost+pushCost)\n            if startAt==targetSeconds:\n                m-=moveCost\n            return m\n        #second part\n        if targetSeconds<100:\n            #max cost\n            m=2*(moveCost+pushCost)\n            h=targetSeconds\n            q=0\n            for b in str(h):\n                q+=leng(int(b))\n                self.z=int(b)\n            mi=m-q*(moveCost)\n        #third part case1\n        if j<10:\n            #max cost\n            m=3*(moveCost+pushCost)\n            #k sholud be in range(0,10) \n            for k in range(j,min(i,9)+1):\n                h=abs(targetSeconds-(k*60))\n                #h=0 but in pratical it should be 00\n                if h==0:\n                    h=\'00\'\n                #if h ==single b=digit in pratical it sholud be 0prefixed\n                elif h<10:\n                    h=str(\'0\')+str(h)\n                #mins+seconds\n                h=str(k)+str(h)\n                q=0\n                for b in str(h):\n                    q+=leng(int(b))\n                    self.z=int(b)\n                #self.z=startAt because we need to restart for next iteration\n                self.z=startAt\n                y=m-q*(moveCost)\n                mi=min(y,mi)\n        if i>=10:\n            #max cost\n            m=4*(moveCost+pushCost)\n            for k in range(max(10,j),i+1):\n                h=abs(targetSeconds-(k*60))\n                #h=0 but in pratical it should be 00\n                if h==0:\n                    h=\'00\'\n                #if h ==single b=digit in pratical it sholud be 0prefixed\n                elif h<10:\n                    h=str(\'0\')+str(h)\n                #mins+seconds\n                h=str(k)+str(h)\n                q=0\n                for i in h:\n                    q+=leng(int(i))\n                    self.z=int(i)\n                #self.z=startAt because we need to restart for next iteration\n                self.z=startAt\n                y=m-q*(moveCost)\n                k=int(k//10)\n                mi=min(y,mi)\n        \n        return mi\n       \n ```\n **PLEASE UPVOTE  MY FRIEND YOU WON\'T LOOSE NOTHING BY UPVOTING!**
['Python']