Py3 cpp速解Leetcode 3635, 3633 Earliest Finish Time for Land and Water Rides
[Py3 解請進]
[codes on Leetcode]https://leetcode.com/problems/earliest-finish-time-for-land-and-water-rides-ii/solutions/8309853/greedy-linearbeats-100-by-anwendeng-wwze/
-----
0:00 Intro & Python Solution Overview
0:09 Solving LeetCode 3635: Earliest Finish Time
0:25 Variable setup & logic breakdown
0:46 Analyzing path options (Land vs. Water)
1:15 Minimum time calculation logic
2:03 Submitting Python code (107ms)
2:12 C++ Solution & Optimization
2:31 Fast result: 0ms execution
#anwendeng
#LC 3635, 3633 Earliest Finish Time for Land and Water Rides
class Solution:
def earliestFinishTime(self, ls: List[int], ld: List[int], ws: List[int], wd: List[int]) -> int:
minLandEnd=min(s+d for s,d in zip(ls, ld))
minWaterEnd=min(s+d for s, d in zip(ws, wd))
lw=min(max(minLandEnd, s)+d for s, d in zip(ws, wd))
wl=min(max(minWaterEnd, s)+d for s,d in zip(ls, ld))
return min(lw, wl)
沒有留言:
張貼留言