C++ Simulation O(1) Time
See my latest update in repo LeetCode\n\n## Solution 1.\n\nOnly two cases, minute = 0, second = target and minute = m, second = target - m * 60. We need to make
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1.\n\nOnly two cases, `minute = 0, second = target` and `minute = m, second = target - m * 60`. We need to make sure both `minute` and `second` are in range `[0, 100)`.\n\nFor a given pair of `minute, second`, we calculate the cost and use the minimum cost as the answer.\n\n```cpp\n// OJ: https://leetcode.com/problems/minimum-cost-to-set-cooking-time/\n// Author: github.com/lzl124631x\n// Time: O(1) since `target` is at most 6039\n// Space: O(1)\nclass Solution {\npublic:\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int target) {\n        int ans = INT_MAX, minute = 0;\n        auto cost = [&](int m, int s) {\n            auto d = to_string(m * 100 + s); // append seconds to minutes and get the digits\n            int x = startAt, ans = 0;\n            for (int i = 0; i < d.size(); ++i) { // simulate the time setting process\n                if (x != d[i] - \'0\') ans += moveCost, x = d[i] - \'0\';\n                ans += pushCost;\n            }\n            return ans;\n        };\n        while (target >= 0) {\n            if (target < 100 && minute < 100) {\n                ans = min(ans, cost(minute, target));\n            }\n            target -= 60;\n            minute++;\n        }\n        return ans;\n    }\n};\n```
[]