👍Runtime 473 ms  Beats 100.00% of users with Scala
Code\n\nobject Solution {\n    def minCostSetTime(startAt: Int, moveCost: Int, pushCost: Int, targetSeconds: Int): Int = {\n        val mins = targetSeconds / 6
# Code\n```\nobject Solution {\n    def minCostSetTime(startAt: Int, moveCost: Int, pushCost: Int, targetSeconds: Int): Int = {\n        val mins = targetSeconds / 60\n        val secs = targetSeconds % 60\n        val firstOption = cost(mins, secs, startAt, moveCost, pushCost)\n        val secondOption = cost(mins - 1, secs + 60, startAt, moveCost, pushCost)\n        Math.min(firstOption, secondOption)\n    }\n\n    private def cost(mins: Int, secs: Int, startAt: Int, moveCost: Int, pushCost: Int): Int = {\n        if (mins > 99 || secs > 99 || mins < 0 || secs < 0) return Int.MaxValue\n        val s = (mins * 100 + secs).toString\n        var curr = (startAt + \'0\').toChar\n        var res = 0\n        for (i <- 0 until s.length) {\n            if (s.charAt(i) == curr) res += pushCost\n            else {\n                res += pushCost + moveCost\n                curr = s.charAt(i)\n            }\n        }\n        res\n    }\n}\n```
['Scala']