Constant time and space (atmost 100 iterations)
\n# Code\n\nclass Solution:\n    def minCostSetTime(self, startAt: int, moveCost: int, pushCost: int, targetSeconds: int) -> int:\n        min_cost = float(\'in
\n# Code\n```\nclass Solution:\n    def minCostSetTime(self, startAt: int, moveCost: int, pushCost: int, targetSeconds: int) -> int:\n        min_cost = float(\'inf\')\n        \n        def calculateCost(time_str, startAt, moveCost, pushCost):\n            cost = 0\n            for digit in time_str:\n                if digit != \'0\' or cost > 0:\n                    cost += moveCost if startAt != int(digit) else 0\n                    cost += pushCost\n                    startAt = int(digit)\n            return cost\n        \n        for minn in range(100):\n            sec = targetSeconds - minn * 60\n            if 0 <= sec < 100:\n                time_str = f\'{minn:02d}{sec:02d}\'\n                cost = calculateCost(time_str, startAt, moveCost, pushCost)\n                min_cost = min(min_cost, cost)\n\n        return min_cost\n\n```
['Python3']