[Python] Clean & Simple, no bitmask
The full problem is NP-hard: https://en.wikipedia.org/wiki/Bin_packing_problem\n\nTo get the exact result, we have to recurse with some smart memorization techn
The full problem is NP-hard: https://en.wikipedia.org/wiki/Bin_packing_problem\n\nTo get the exact result, we have to recurse with some smart memorization techniques.\n\nI still find it challenging to use bitmask, so here is the dfs version.\n\nComparing to the default dfs which gets TLE, the trick here is to loop through the sessions, rather than the tasks themselves.\n\n```python\nclass Solution:\n    def minSessions(self, tasks: List[int], sessionTime: int) -> int:\n        n = len(tasks)\n        tasks.sort(reverse=True)\n        sessions = []\n        result = [n]\n        \n        def dfs(index):\n            if len(sessions) > result[0]:\n                return\n            if index == n:\n                result[0] = len(sessions)\n                return\n            for i in range(len(sessions)):\n                if sessions[i] + tasks[index] <= sessionTime:\n                    sessions[i] += tasks[index]\n                    dfs(index + 1)\n                    sessions[i] -= tasks[index]\n            sessions.append(tasks[index])\n            dfs(index + 1)\n            sessions.pop()\n        \n        dfs(0)\n        return result[0]\n```
['Python']