Skip to content

Commit

Permalink
Time: 2115 ms (48.35%), Space: 17.8 MB (20.25%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
KangminLim committed Dec 30, 2024
1 parent 857643d commit d7a13fd
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution:
def minimumTimeRequired(self, jobs: List[int], k: int) -> int:
answer = sum(jobs)
# v = [False] * len(jobs)
wt = [0] * k
jobs.sort()
def bt(idx,wt):
nonlocal answer,k
if idx == len(jobs):
answer = min(answer,max(wt))
return

for i in range(len(wt)):
if jobs[idx] + wt[i] <= answer:
wt[i] += jobs[idx]
bt(idx+1,wt)
wt[i] -= jobs[idx]
if wt[i] == 0:
break
bt(0,wt)
return answer

0 comments on commit d7a13fd

Please sign in to comment.