Java Modular Code || Easy to Understand
Code\n\nclass Solution {\n    public int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        List<Integer> times = buildTime(t
# Code\n```\nclass Solution {\n    public int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        List<Integer> times = buildTime(targetSeconds);\n        int minCost = Integer.MAX_VALUE;\n        for (int time: times) {\n            int cost = 0;\n            int localStart = startAt;\n            int divisor = (int) Math.pow(10, getNoOfDigits(time)-1);\n            while (divisor > 0) {\n                int digit = time / divisor;\n                if (digit != localStart) {\n                    cost += moveCost;\n                }\n                cost += pushCost;\n                localStart = digit;\n                time %= divisor;\n                divisor /= 10;\n            }\n            minCost = Math.min(minCost, cost);\n        }\n        return minCost;\n    }\n\n    private int getNoOfDigits(int num) {\n        int count = 0;\n        while (num > 0) {\n            num /= 10;\n            count++;\n        }\n        return count;\n    }\n\n    private List<Integer> buildTime(int targetSeconds) {\n        int min = targetSeconds / 60;\n        int sec = targetSeconds % 60;\n        List<Integer> list = new ArrayList<>();\n        if (min < 100) {\n            if (min > 0) list.add(min * 100 + sec);\n            else list.add(sec);\n        }\n        if (min > 0 && sec+60 < 100) {\n            min -= 1; \n            sec += 60;\n            if (min > 0) list.add(min * 100 + sec);\n            else list.add(sec);\n        }\n        return list;\n    }\n}\n```
['Java']