Solved without skills
Honestly, I solved it by adding more and more conditions.\n\nThe basic idea is to check if N sessions are enough and do binary search on N.\n\nSome optimization
Honestly, I solved it by adding more and more conditions.\n\nThe basic idea is to check if `N` sessions are enough and do binary search on `N`.\n\nSome optimizations are:\n- Sorts tasks. Processing heavy tasks first result in early rejections.\n- The minimum possible \'N\' is `max(1, sum(tasks) // sessionTime)`.\n- If a task is dispatched to an empty session, no need to check the other sessions. Because the remain (unchecked) sessions are also empty.\n\n```python\nclass Solution:\n    def minSessions(self, tasks: List[int], sessionTime: int) -> int:\n        def process_task(idx_task, buckets):\n            if idx_task == len(tasks):\n                return True\n            for i in range(len(buckets)):\n                if buckets[i] + tasks[idx_task] <= sessionTime:\n                    buckets[i] += tasks[idx_task]\n                    if process_task(idx_task + 1, buckets):\n                        return True\n                    buckets[i] -= tasks[idx_task]\n                    if buckets[i] == 0:\n                        return False\n            return False\n\n        def possible(num_buckets):\n            buckets = [0 for _ in range(num_buckets)]\n            buckets[0] = tasks[0]\n            return process_task(1, buckets)\n        \n        tasks.sort(reverse=True)\n        \n        l, r = max(1, sum(tasks) // sessionTime), len(tasks)\n\n        while l < r:\n            m = (l + r) // 2\n            \n            if possible(m):\n                r = m\n            else:\n                l = m + 1\n\n        return l\n```
['Binary Search', 'Python']