Python Backtracking /w pruning
\nclass Solution:\n    def minSessions(self, tasks: List[int], sessionTime: int) -> int:\n        \n        sessions = []\n        \n        self.ans = n = len(
```\nclass Solution:\n    def minSessions(self, tasks: List[int], sessionTime: int) -> int:\n        \n        sessions = []\n        \n        self.ans = n = len(tasks)\n        \n        def backtracking(i):\n            \n            # pruning\n            if len(sessions) >= self.ans:\n                return\n            \n            if i == n:\n                self.ans = min(self.ans, len(sessions))\n                return\n\n            # try to put it in every exist sesssions, or create a new one\n            for s_idx in range(len(sessions)):\n                if sessions[s_idx] + tasks[i] <= sessionTime:\n                    sessions[s_idx] += tasks[i]\n                    backtracking(i+1)\n                    sessions[s_idx] -= tasks[i]\n                    \n            sessions.append(tasks[i])\n            backtracking(i+1)\n            sessions.pop()\n            \n        backtracking(0)\n        return self.ans\n```
[]