Java DFS solution beating 100 %
```\nclass Solution {\n    public int minSessions(int[] tasks, int sessionTime) {\n        // sort desendingly\n        // we know that the minSessionTimes is b
```\nclass Solution {\n    public int minSessions(int[] tasks, int sessionTime) {\n        // sort desendingly\n        // we know that the minSessionTimes is between 1 to # number of tasks\n        // then we can use dfs to find from 1 to n, which one works first\n        // Copy Right to a classmate.\n        Arrays.sort(tasks);\n        int s = 0, t = tasks.length - 1;\n        while (s <= t) {\n            int temp = tasks[s];\n            tasks[s] = tasks[t];\n            tasks[t] = temp;\n            s++;\n            t--;\n        }\n        \n        for (int n = 1; n < tasks.length; n++) {\n            int[] remain = new int[n];\n            for (int i = 0; i < n; i++) {\n                remain[i] = sessionTime;\n            }\n            if (canWork(tasks, 0, remain)) return n;\n        }\n        return tasks.length;\n    }\n    \n    private boolean canWork(int[] tasks, int curr, int[] remain) {\n        if (curr == tasks.length) return true;\n        for (int i = 0; i < remain.length; i++) {\n            if (i > curr) continue; // if i th bucket\'s index is bigger that current task\'s index, we continue as it\'s impossible bc the worst east is that i == index when worksession is equal to task time.\n            if (remain[i] >= tasks[curr]) {\n                remain[i] -= tasks[curr];\n                if (canWork(tasks, curr + 1, remain)) return true;\n                remain[i] += tasks[curr];\n            }\n        }\n        return false;\n    }\n}
[]