C++ | Recursive Solution | Beats 100% | 0ms
Here is my brute force recursive solution that beats 100%\n\ncpp\nclass Solution {\npublic:\n    int dp(int moveCost, int pushCost, int targetSeconds, int lastD
Here is my brute force recursive solution that beats 100%\n\n```cpp\nclass Solution {\npublic:\n    int dp(int moveCost, int pushCost, int targetSeconds, int lastDigit, int idx)\n    {\n        if (targetSeconds < 0)\n            return INT_MAX;\n        \n        if (idx == 1) {\n            if (targetSeconds >= 10) {\n                return INT_MAX;\n            }else{\n                return lastDigit == targetSeconds ? pushCost : pushCost + moveCost;\n            }\n        }\n        \n        if (targetSeconds == 0)\n            return dp(moveCost, pushCost, targetSeconds, 0, idx - 1) + (lastDigit == 0 ? pushCost : pushCost + moveCost);\n        \n        int m = idx == 4 ? 60*10 : (idx == 3 ? 60 : (idx == 2 ? 10 : 1));\n        int result = INT_MAX;\n        \n        for (int i = 0; i <= 9; i++) {\n            if (m * i <= targetSeconds) {\n                int cost = dp(moveCost, pushCost, targetSeconds - m * i, i, idx - 1);\n                if (cost != INT_MAX) {\n                    result = min(result, cost + (lastDigit == i ? pushCost : pushCost + moveCost));\n                }\n            }\n        }\n        \n        return result;\n    }\n    \n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        int mn = INT_MAX;\n        for (int i = 4; i >= 1; i--) {\n            mn = min(mn, dp(moveCost, pushCost, targetSeconds, startAt, i));\n        }\n        return mn;\n    }\n};\n```
['Recursion', 'C']