Tap here to switch tabs
Problem
Submissions

Problem: Earliest Finish Time for Land and Water Rides II

Earliest Finish Time for Land and Water Rides II asks you to use opening times and durations to choose one land ride and one water ride in either order, then return the earliest time both are finished.

Statement

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

There are nn land rides and mm water rides available:

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

  • The jthj^{ {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≤5×1041 \leq n, m \leq 5 \times 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

Earliest Finish Time for Land and Water Rides II asks you to use opening times and durations to choose one land ride and one water ride in either order, then return the earliest time both are finished.

Statement

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

There are nn land rides and mm water rides available:

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

  • The jthj^{ {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≤5×1041 \leq n, m \leq 5 \times 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