Repeatedly select 2 numbers (all combinations) and compute, until there is only one number, check if it's 24.

```
class Solution {
public boolean judgePoint24(int[] nums) {
return f(new double[] {nums[0], nums[1], nums[2], nums[3]});
}
private boolean f(double[] a) {
if (a.length == 1) {
return a[0] == 24;
}
for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
double[] b = new double[a.length - 1];
for (int k = 0, l = 0; k < a.length; k++) {
if (k != i && k != j) {
b[l++] = a[k];
}
}
for (double k : compute(a[i], a[j])) {
b[a.length - 2] = k;
if (f(b)) {
return true;
}
}
}
}
return false;
}
private double[] compute(double a, double b) {
return new double[] {a + b, a - b, b - a, a * b, a / b, b / a};
}
}
```