Java | Not easy to understand
\nclass Solution\n{\n    public int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds)\n    {\n            int min1 = 0, min2 = 0;\n    
```\nclass Solution\n{\n    public int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds)\n    {\n            int min1 = 0, min2 = 0;\n            int[] num1 = new int[4]; // Storing each digits\n            num1[0] = (targetSeconds/60)/10;\n            num1[1] = (targetSeconds/60)%10;\n            num1[2] = (targetSeconds%60)/10;\n            num1[3] = (targetSeconds%60)%10;\n            if(targetSeconds >= 6000) // Upper limit is 99 minutes\n            {\n                num1[0] = 9;\n                num1[1] = 9;\n                num1[2] += 6;\n            }\n            int cur = 3; \n            int cur_dig = startAt; // Stores last pressed number\n            boolean zero = true; // To avoid leading zeroes\n            while(cur >= 0)\n            {\n                if(num1[3-cur] != 0)\n                    zero = false;\n                if(zero && num1[3-cur] == 0) // Leading zeroes\n                {\n                    cur--;\n                    continue;\n                }\n                min1 += minCost(cur_dig, moveCost, pushCost, num1[3-cur]);\n                cur_dig = num1[3-cur];\n                cur--;\n            }\n            cur = 3;\n            if(targetSeconds < 60 || targetSeconds >= 5980 || num1[2]>=4) // Cases where only one way to reach the duration\n                return min1;\n            if(num1[1] == 0) // If minutes are 10,20,30 etc, next would be 9,19,29 and so on\n            {\n                num1[1] = 9;\n                num1[0]--;\n            }\n            else // If not 10,20,30, then simply one lesser, e.g. 19 -> 18\n                num1[1]--;\n            num1[2]+=6;\n            zero = true;\n            cur_dig = startAt;\n            while(cur >= 0)\n            {                 \n                if(num1[3-cur] != 0)\n                    zero = false;\n                if(zero && num1[3-cur] == 0)\n                {\n                    cur--;\n                    continue;       \n                }\n                min2 += minCost(cur_dig, moveCost, pushCost, num1[3-cur]);\n                cur_dig = num1[3-cur];\n                cur--;\n            }\n            return Math.min(min1,min2);\n    }\n    private static int minCost(int cur,int move, int push, int target)\n    {\n        if(target != cur)\n            return move+push;\n        else\n            return push;\n    }\n}\n```
['Java']