JAVA Binary Search 2ms Solution,  same as Problem 1723. Find Minimum Time to Finish All Jobs
Minimum Number of Work Sessions to Finish the Tasks\n\n    public int minSessions(int[] tasks, int sessionTime) {\n        Arrays.sort(tasks);\n        int lo =
1986. Minimum Number of Work Sessions to Finish the Tasks\n```\n    public int minSessions(int[] tasks, int sessionTime) {\n        Arrays.sort(tasks);\n        int lo = 1, hi = tasks.length;\n\n        while (lo < hi) {\n            int numSessions = (lo + hi) / 2;\n            if (canSchedule(tasks, new int[numSessions], tasks.length - 1, sessionTime))\n                hi = numSessions;\n            else\n                lo = numSessions + 1;\n        }\n        return lo;\n    }\n\n    private boolean canSchedule(int[] tasks, int[] sessions, int taskIdx, int sessionTime) {\n        if (taskIdx == -1) return true;\n\n        Set<Integer> set = new HashSet<>();\n        for (int i = 0; i < sessions.length; i++) {\n            if (!set.add(sessions[i])) continue;\n            if (tasks[taskIdx] + sessions[i] > sessionTime) continue;\n\n            sessions[i] += tasks[taskIdx];\n            if (canSchedule(tasks, sessions, taskIdx - 1, sessionTime))\n                return true;\n            sessions[i] -= tasks[taskIdx];\n        }\n\n        return false;\n    }\n```\n\n1723. Find Minimum Time to Finish All Jobs\n```\n        public int minimumTimeRequired(int[] jobs, int workers) {\n            Arrays.sort(jobs);\n            int n = jobs.length;\n            int lo = jobs[n - 1], hi = Arrays.stream(jobs).sum();\n\n            while (lo < hi) {\n                int maxTime = lo + (hi - lo) / 2;\n                if (canSchedule(jobs, new int[workers], n - 1, maxTime))\n                    hi = maxTime;\n                else\n                    lo = maxTime + 1;\n            }\n            return lo;\n        }\n\n        private boolean canSchedule(int[] jobs, int[] workload, int jobIdx, int maxTime) {\n            if (jobIdx == -1) return true;\n\n            Set<Integer> set = new HashSet<>();\n            for (int i = 0; i < workload.length; i++) {\n                if (!set.add(workload[i])) continue;\n                if (jobs[jobIdx] + workload[i] > maxTime) continue;\n\n                workload[i] += jobs[jobIdx];\n                if (canSchedule(jobs, workload, jobIdx - 1, maxTime))\n                    return true;\n                workload[i] -= jobs[jobIdx];\n            }\n\n            return false;\n        }\n```
[]