Space Station Shuttle Missions
Learn this problemProblem statement
A space-station network has two hubs, Alpha and Beta. Shuttle departures from Alpha to Beta are given by the sorted integer array alpha2beta, and departures from Beta to Alpha are given by the sorted integer array beta2alpha.
Every shuttle trip takes exactly 100 time units. Your journey starts at Alpha at time 0.
Complete missions missions. Each mission consists of traveling from Alpha to Beta and then returning from Beta to Alpha. For every leg, take the earliest shuttle whose departure time is at or after your arrival at that hub.
Return the time when all missions are complete. The schedules guarantee that every required leg can be completed.
Function
completeShuttleMissions(alpha2beta: int[], beta2alpha: int[], missions: int) → intExamples
Example 1
alpha2beta = [0,200,500]beta2alpha = [99,210,450]missions = 1return = 310Take the Alpha-to-Beta shuttle at time 0 and arrive at Beta at time 100. The earliest available return shuttle departs at time 210, so the mission finishes at Alpha at time 310.
Example 2
alpha2beta = [0,300,700]beta2alpha = [150,500,900]missions = 2return = 600The first mission uses departures 0 and 150, finishing at time 250. The second uses departures 300 and 500, finishing at time 600.
Example 3
alpha2beta = [100,400]beta2alpha = [200,500]missions = 2return = 600After departing Alpha at 100, you arrive at Beta exactly when the shuttle at 200 departs. The second mission similarly uses departures 400 and 500, so all missions finish at time 600.
Constraints
alpha2betaandbeta2alphaare sorted arrays of integer departure times.- Every Alpha-to-Beta and Beta-to-Alpha trip takes exactly
100time units. - For every required leg, the corresponding schedule contains an available departure at or after the current time.
More Tiktok problems
- Concatenate Digit-wise SumsOA · Seen Aug 2026
- Count 2x2 Submatrices by Black CellsOA · Seen Aug 2026
- Count House Segments After DestructionOA · Seen Aug 2026
- Debugger Breakpoint ActionsOA · Seen Aug 2026
- Distribution Center Package AllocationOA · Seen Aug 2026
- Find All Local PeaksOA · Seen Aug 2026
- Minimum Height Difference Between Distant PeaksOA · Seen Aug 2026
- Minimum Operations for Stepwise StructuresOA · Seen Aug 2026