[python] walk bucket solution, easy to understand
this problem is similar to problem 1723.\nthe solution is straightforward. there are n tasks, so we create n bucket. each task[i] will be placed to one of the b
this problem is similar to problem 1723.\nthe solution is straightforward. there are n tasks, so we create n bucket. each task[i] will be placed to one of the bucket. the non-empty bucket is the number of sessions and we want to find the min.\nBelow is the code. \nfunction walk will walk through every task and try to place it to one bucket(session), k is the current non empty  bucket, which is the sessions we used so far.\nself.res is the current best result\nI did several pruning here\n1. if k larger than self.res, then we don\'t need to search forward anymore.\n2. for each task ,when we iterate all bucket, if the bucket value is the same, then we only need to calcuate one of them. this why I used seen set to track bucket value that has been used.\n\n\n\n```\nclass Solution:\n    def minSessions(self, tasks: List[int], sessionTime: int) -> int:\n        n=len(tasks)\n        tasks.sort(reverse=True)\n        self.res=n\n        sessions=[0]*n\n        def walk(i,k):\n            if k>=self.res:\n                return\n            if i==n:\n                self.res=min(self.res,k)\n                return\n            seen=set()\n            for j in range(n):\n                if sessions[j] in seen:\n                    continue\n                if sessions[j]+tasks[i]<=sessionTime:\n                    seen.add(sessions[j])\n                    if sessions[j]==0:\n                        sessions[j]+=tasks[i]\n                        walk(i+1,k+1)\n                    else:\n                        sessions[j]+=tasks[i]\n                        walk(i+1,k)\n                    sessions[j]-=tasks[i]\n            return \n        walk(0,0)\n        return self.res\n```\n\n\n
[]