c++ solution
\nclass Solution {\npublic:\n    int getSeconds(int time) {\n        int a = time % 10;\n        time /= 10;\n        int b = time % 10;\n        time /= 10;\n 
```\nclass Solution {\npublic:\n    int getSeconds(int time) {\n        int a = time % 10;\n        time /= 10;\n        int b = time % 10;\n        time /= 10;\n        int c = time % 10;\n        time /= 10;\n        int d = time % 10;\n        time /= 10;\n        int seconds = b * 10 + a;\n        int minutes = d * 10 + c;\n        return minutes * 60 + seconds;\n    }\n    int ans = 1e9 + 7;\n    void dfs(int current, int time, int moveCost, int pushCost, int targetSeconds, int pos, int cost) {\n        if(pos == 4) {\n            if(targetSeconds == getSeconds(time)) {\n                ans = min(ans, cost);\n            }\n            return;\n        }\n        if(targetSeconds == getSeconds(time)) {\n            ans = min(ans, cost);\n        }\n        for(int i = 0; i < 10; i++) {\n            if(current == i) {\n                dfs(current, time * 10 + i, moveCost, pushCost, targetSeconds, pos + 1, cost + pushCost);\n            }\n            else {\n                dfs(i, time * 10 + i, moveCost, pushCost, targetSeconds, pos + 1, cost + moveCost + pushCost);\n            }\n        }\n        \n    }\n    int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        dfs(startAt, 0, moveCost, pushCost, targetSeconds, 0, 0);\n        return ans;\n    }\n};\n```
[]