classSolution:defshipWithinDays(self,weights: List[int],days:int) ->int: left =max(weights) right =sum(weights)+1defhelper(capacity): days =1 acc =0for weight in weights:if acc + weight > capacity: acc = weight days +=1else: acc += weightreturn dayswhile left < right: mid = left + (right - left) //2ifhelper(mid)<= days: right = midelse: left = mid +1return left