CPythonLeetcode每日一题 —— 最早完成陆地和水上游乐设施的时间 I 中发帖

贪心,最早水上或者陆地(尽可能早点完成),之后遍历,时间复杂度:O(N) 
class Solution:
    def earliestFinishTime(self, landStartTime: List[int], landDuration: List[int], waterStartTime: List[int], waterDuration: List[int]) -> int:
        ans = lf = wf = inf
        n1, n2 = len(landStartTime), len(waterDuration)
        for i in range(n1):
            lf = min(lf, landStartTime[i] + landDuration[i])
        for j in range(n2):
...
 
 
Back to Top