Brute Force ans Easy to Understand || 0 ms || Beats 100.00%
Intuition\n Describe your first thoughts on how to solve this problem. \nOnly 4 digits (1 ~ 9999)\n\n# Approach\n Describe your approach to solving the problem.
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOnly 4 digits (1 ~ 9999)\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGenerate all possible ways for 4 digits (1 ~ 9999), and check the total seconds for each way, if same as targetSeconds, caculate the cost and keep the minimum one.\n\n# Complexity\n- Time complexity: O(9999)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\n    int startAt, moveCost,  pushCost;\n    int costTime(string s) {\n        int ans = 0;\n        int N = s.size();\n        for (int i = 0 ; i < N ; i++) {\n            if (i == 0) {\n                if ((s[i]-\'0\') != startAt)    ans += moveCost;\n            }\n            else {\n                if (s[i] != s[i-1])           ans += moveCost;\n            }\n            ans += pushCost;\n        }\n        return ans;\n    }\npublic:\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        this->startAt = startAt;\n        this->moveCost = moveCost;\n        this->pushCost = pushCost;\n        int ans = INT_MAX;\n        for (int i = 1 ; i <= 9999 ; i++) {\n            if (((i/100*60) + (i%100)) == targetSeconds) {\n                // printf("Check %d\\n", i);\n                ans = min(ans, costTime(to_string(i)));\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']