maximum-profit-in-job-scheduling

LeetCode - The World's Leading Online Programming Learning Platform

class Solution:
    def jobScheduling(self, startTime: List[int], endTime: List[int], profit: List[int]) -> int:
        jobs=sorted(zip(startTime,endTime,profit), key=lambda v: v[1])
        dp = [[0, 0]]
        for s, e, p in jobs:
            i =bisect.bisect(dp,[s+1])-1
            if dp[i][1]+p>dp[-1][1]:
                dp.append([e,dp[i][1]+p])
        
        return dp[-1][1]

找右侧插入点

你可能感兴趣的:(leetcode)