#3633

Earliest Finish Time for Land and Water Rides I

pupil · 380 · lc easy +24 · 61.7% accepted · 68 likes · top 62%

Description

Land rides and water rides are given: landStartTime[i] and landDuration[i] describe each land ride; waterStartTime[j] and waterDuration[j] describe each water ride.

A tourist must complete exactly one ride from each category in any order. A ride starts at or after its opening time; starting at time t means finishing at t + duration. The next ride can begin immediately after the first finishes (or must wait if not yet open).

Return the earliest time the tourist finishes both rides.

Code

1
2
3