✅ Easy to understand JS Solution with explanation
Intuition:\n\nThe idea is first we need to think that in how many ways we can get targetSeconds so that we can maintain the constraint of mm:ss i.e 99:99. And f
Intuition:\n\nThe idea is first we need to think that in how many ways we can get targetSeconds so that we can maintain the constraint of mm:ss i.e 99:99. And from those ways we need one possible combination such that we get less tired(moving + pushing those buttons).\n\n**Example 1:**  if we have targetSeconds of 400 seconds:\n\n```\n1st way       400 sec ( _ _ : _ _) i.e ( 0 0: 400 )\n              -60\n              -----\n2nd way       340 sec ( _ _ : _ _) i.e ( 0 1: 340 ) <--- cannot be arranged here\n              -60\n\t\t\t  -----\n3rd way       280 sec ( _ _ : _ _) i.e ( 0 2: 280 )<-- neither here\n              -60\n              -----\n4th way       220 sec ( _ _: _ _) i.e ( 0 3: 220 ) <-- neither here\n              -60\n             -----\n5th way.      160 sec ( _ _: _ _) i.e ( 0 4: 160 ) <-- neither here\n              -60\n              -----\n6th           100 sec ( _ _: _ _) i.e ( 0 5: 100 ) <-- neither here\n              -60\n              -----\n               40 sec ( 0 6: 4 0) <-- here we can achieve our constraint ( <=99: <=99 )\n```\n\nHence we can see that 1 to 5 can not be part of minimum cost as they do not follow our constraint of ( <=99: <=99 ). For these we simply continue and for 6 we generate our cost, which will be the minimum.\n\n\n**Example 2:**  targetSeconds of 99 seconds:\n```\n1st way   99 sec ( _ _ : _ _) i.e ( 0 0: 99 )  <-- can be arranged in mm:ss\n         -60\n\t\t -----\n2n way    39 sec ( _ 1 : _ _) i.e ( 0 1: 39 )  <-- can be arranged in mm:ss\n```\n\nHence we see 1 and 2 both fulfill our criteria of ( <=99: <=99 ) and both of them will contribute to our minimum cost logic\n\n**CODE**\n\n```\n/**\n * @param {number} startAt\n * @param {number} moveCost\n * @param {number} pushCost\n * @param {number} targetSeconds\n * @return {number}\n */\nvar minCostSetTime = function(startAt, moveCost, pushCost, targetSeconds) {\n    let cost = Infinity;\n    \n    let maxMinutes = Math.floor(targetSeconds / 60);\n    \n    for(let min = 0; min <= maxMinutes; min++) {\n        let secs = targetSeconds - min * 60;\n        \n        if (secs > 99 || min > 99) continue;\n        \n        let buttons = String(100 * min + secs);\n        let prev = Number(buttons[0]);\n        \n        let sum = 0;\n        \n        //start index will vary according to startAt pointer\n        let start = 0;\n        \n        //If startAt is equal to first button, we need to add pushCost fatigue\n        if(prev === startAt) {\n            sum += pushCost;\n            start = 1;\n         } else {\n            //Else we need to add moveCost fatigue\n            sum += moveCost;\n         }\n        \n        for(let i = start; i < buttons.length; i++) {\n            let button = Number(buttons[i]);\n            \n            if(button !== prev) {\n                sum += moveCost + pushCost;\n            } else {\n                sum += pushCost;\n            }\n            \n            prev = button;\n        }\n        \n        cost = Math.min(cost, sum)\n    }\n    \n    return cost;\n};\n```\n\nNote: This is JS version of https://leetcode.com/problems/minimum-cost-to-set-cooking-time/discuss/1746988/Python3-Java-C%2B%2B-Combinations-of-Minutes-and-Seconds-O(1) Solution\n\nHope it helps!
['JavaScript']