Tap here to switch tabs
Problem
Submissions

Problem: Earliest Finish Time for Land and Water Rides II

med
30 min
Try to solve the Earliest Finish Time for Land and Water Rides II problem.

Statement

You are given four integer arrays: landStartTime, landDuration, waterStartTime, and waterDuration.

There are nn land rides and mm water rides available:

  • The iextthi^{ ext{th}} land ride opens at time landStartTime[i] and takes landDuration[i] time to complete.

  • The jextthj^{ ext{th}} water ride opens at time waterStartTime[j] and takes waterDuration[j] time to complete.

You must complete exactly one land ride and exactly one water ride in any order.

A ride cannot begin before its opening time. If you arrive at a ride after it opens, you may start it immediately.

Return the earliest possible time by which you can finish both rides.

Constraints:

  • 1≤n,m≤5imes1041 \leq n, m \leq 5 imes 10^4

  • landStartTime.length ==== landDuration.length ==n== n

  • waterStartTime.length ==== waterDuration.length ==m== m

  • 1≤1 \leq landStartTime[i], landDuration[i], waterStartTime[j], waterDuration[j] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Earliest Finish Time for Land and Water Rides II

med
30 min
Try to solve the Earliest Finish Time for Land and Water Rides II problem.

Statement

You are given four integer arrays: landStartTime, landDuration, waterStartTime, and waterDuration.

There are nn land rides and mm water rides available:

  • The iextthi^{ ext{th}} land ride opens at time landStartTime[i] and takes landDuration[i] time to complete.

  • The jextthj^{ ext{th}} water ride opens at time waterStartTime[j] and takes waterDuration[j] time to complete.

You must complete exactly one land ride and exactly one water ride in any order.

A ride cannot begin before its opening time. If you arrive at a ride after it opens, you may start it immediately.

Return the earliest possible time by which you can finish both rides.

Constraints:

  • 1≤n,m≤5imes1041 \leq n, m \leq 5 imes 10^4

  • landStartTime.length ==== landDuration.length ==n== n

  • waterStartTime.length ==== waterDuration.length ==m== m

  • 1≤1 \leq landStartTime[i], landDuration[i], waterStartTime[j], waterDuration[j] ≤105\leq 10^5