Jav | All Possible Permutation
\nclass Solution {\n    public int solve(List<Integer> list, int startAt, int moveCost, int pushCost){\n        int res = 0;\n        if(list.get(0) != startAt)
```\nclass Solution {\n    public int solve(List<Integer> list, int startAt, int moveCost, int pushCost){\n        int res = 0;\n        if(list.get(0) != startAt){\n            res+=moveCost;\n        }\n        res+=pushCost;\n        \n        for(int i=1; i<list.size(); i++){\n            if(list.get(i) != list.get(i-1))\n                res+=moveCost;\n            res+=pushCost;\n        }\n        return res;\n    }\n    public int minCostSetTime(int startAt, int moveCost, int pushCost, int targetSeconds) {\n        int cost=(int) 1e8;\n        /*\n            Just make all possible combinations of 4 digit number from 0-9\n            \n        */\n        for(int i=0; i<=9; i++){\n            for(int j=0; j<=9; j++){\n                for(int k=0; k<=9; k++){\n                    for(int l=0; l<=9; l++){\n                        \n                        List<Integer> list=new ArrayList<>();\n                        \n                        int sec = i*10*60 + j*60 + k*10 + l;\n                        \n                        if(sec == targetSeconds){\n                            list.add(i);\n                            list.add(j);\n                            list.add(k);\n                            list.add(l);\n                            \n                            cost=Math.min(cost, solve(list, startAt, moveCost, pushCost));\n                            \n                            while(list.get(0) == 0){\n                                list.remove(0);\n                                cost=Math.min(cost, solve(list, startAt, moveCost, pushCost));\n                            }\n                        }\n                    }\n                }\n            }\n        }\n        \n        return cost;\n    }\n}\n```
['Probability and Statistics', 'Java']