All Questions
Next Question
Nomadic Manager
00:00:00
Parts
Part 1
In New York City, there is a select group of hedge fund managers that cherish any opportunity they get to travel. As a result, they often fly from state to state to conduct business meetings and other managerial activities.
Given a table of flights that the managers took, find the second flight with the largest travel duration between each pair of cities. Order the flights by the flight id in ascending order.
Note: For any two cities A and B, (takeoff_location=A, arrival_location=B)
and (takeoff_location=B, arrival_location=A)
are counted as the same pair of cities.
Example Output
id | takeoff_location | arrival_location | flight_start | flight_end |
---|---|---|---|---|
1 | New York City | Boston | 2023-05-01T12:00:00 | 2023-05-01T16:00:00 |
2 | Seattle | San Francisco | 2023-05-03T1:00:00 | 2023-05-05T6:00:00 |
3 | Orlando | Boston | 2023-05-05T18:00:00 | 2023-05-05T22:00:00 |
Input Tables
flights
Column Name | Data Type |
---|---|
id | bigint |
takeoff_location | text |
arrival_location | text |
plane_id | bigint |
flight_start | datetime |
fligth_end | datetime |