Beats 100%
Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\n    fun minCostSetTime(\n        startAt: Int,\n        moveCos
# Complexity\n- Time complexity:\n$$O(1)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\n    fun minCostSetTime(\n        startAt: Int,\n        moveCost: Int,\n        pushCost: Int,\n        targetSeconds: Int\n    ): Int {\n        val minutes = targetSeconds / 60\n        val seconds = targetSeconds % 60\n\n        return min(\n            calculateMinCost(minutes, seconds, startAt, moveCost, pushCost),\n            calculateMinCost(minutes - 1, seconds + 60, startAt, moveCost, pushCost)\n        )\n    }\n\n    private fun calculateMinCost(\n        minutes: Int,\n        seconds: Int,\n        startAt: Int,\n        moveCost: Int,\n        pushCost: Int,\n    ) : Int {\n        var prevDigit = startAt\n        if(minutes !in 0..99 || seconds !in 0..99) return Int.MAX_VALUE\n\n        val digit = intArrayOf(minutes / 10, minutes % 10, seconds / 10, seconds % 10)\n\n        var index = 0\n        while(index < 4 && digit[index] == 0) {\n            index++\n        }\n\n        var totalCost = 0\n\n        while(index < 4) {\n            if(digit[index] != prevDigit) {\n                totalCost += moveCost\n            }\n            totalCost += pushCost\n\n            prevDigit = digit[index]\n            index++\n        }\n        return totalCost\n    }\n}\n```
['Array', 'Math', 'Enumeration', 'Kotlin']