clean java memory dfs
\nclass Solution {\n    int[][][][] mem = new int[29][29][29][2];\n    public int[] earliestAndLatest(int n, int f, int s) {\n        return helper(n, f - 1, s 
```\nclass Solution {\n    int[][][][] mem = new int[29][29][29][2];\n    public int[] earliestAndLatest(int n, int f, int s) {\n        return helper(n, f - 1, s - 1);\n    }\n    \n    public int[] helper(int n, int f, int s) {\n        if (f == n - 1 - s){\n            return new int[]{1, 1};\n        }\n        if (mem[n][f][s][0] != 0){\n            return mem[n][f][s];\n        }\n        int m = 1 << (n / 2);\n        int[] ret = new int[]{Integer.MAX_VALUE, 0};\n        for (int i = 0; i < m; i++){\n            boolean[] del = new boolean[n];\n            if (n - 1 - f != f){\n                del[n - 1 - f] = true;\n            }\n            if (n - 1 - s != s){\n                del[n - 1 - s] = true;\n            }\n            for (int j = 0; j < n / 2; j++){\n                if (j == f || j == s || del[j]){\n                    continue;\n                }\n                if ((i & (1 << j)) != 0){\n                    del[j] = true;\n                }else{\n                    del[n - 1 - j] = true;\n                }\n            }\n            int cnt = 0, newF = 0, newS = 0;\n            for (int j = 0; j < n; j++){\n                if (del[j]){\n                    continue;\n                }\n                if (j == f){\n                    newF = cnt;\n                }\n                if (j == s){\n                    newS = cnt;\n                }\n                cnt++;\n            }\n            int[] ans = helper(cnt, newF, newS);\n            ret[0] = Math.min(ret[0], ans[0] + 1);\n            ret[1] = Math.max(ret[1], ans[1] + 1);\n        }\n        mem[n][f][s] = ret;\n        return ret;\n    }\n}\n```
[]