Fast and Intuitive Java solution 2ms beats 86%
The algorithm is simple, pick 2 values at a time, and try all possible combination of operators on it, and create a new array that you pass to the next recusive
The algorithm is simple, pick 2 values at a time, and try all possible combination of operators on it, and create a new array that you pass to the next recusive call.\nif  the array length is 1, we check to see if the number if 24\n\n```\nclass Solution {\n    public boolean judgePoint24(int[] nums) {\n        double[] doubleArr = new double[nums.length];\n        int index = 0;\n        for (int num: nums) {\n            doubleArr[index++] = num;\n        }\n        return dfs(doubleArr);\n    }\n    \n    public boolean dfs(double[] nums) {\n        if (nums.length == 1) {\n            return Math.abs(24 - nums[0]) < 10e-5 ;\n        }\n        double[] newArr = new double[nums.length - 1];\n        \n        for (int i = 0; i < nums.length; i++) {\n            for (int j = 0; j < nums.length; j++) {\n                if (i == j) continue;\n                int index = 0;\n                \n\t\t\t\t// put all the values we\'re not using yet into the array\n                for (int z = 0; z < nums.length; z++) {\n                    if (z == i || z == j) continue;\n                    newArr[index++] = nums[z];\n                }\n\t\t\t\t\n\t\t\t\t//Try all combinations\n                newArr[index] = nums[i] - nums[j];\n                if (dfs(newArr)) return true;\n                \n                newArr[index] = nums[j] - nums[i];\n                if (dfs(newArr)) return true;\n                \n                newArr[index] = nums[i] * nums[j];\n                if (dfs(newArr)) return true;\n                \n                newArr[index] = nums[i] + nums[j];\n                if (dfs(newArr)) return true;\n                \n                if (nums[j] != 0) {\n                    newArr[index] = nums[i] / nums[j];\n                    if (dfs(newArr)) return true;\n                }\n                \n                if (nums[i] != 0) {\n                    newArr[index] = nums[j] / nums[i];\n                    if (dfs(newArr)) return true;\n                }\n            }\n        }\n        return false;\n    }\n}\n```
[]