Preparing for your next Quant Interview?
Practice Here!
OpenQuant
All Questions
Next Question
Nomadic Manager
00:00:00
3/10
Data Wrangling
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

idtakeoff_locationarrival_locationflight_startflight_end
1New York CityBoston2023-05-01T12:00:002023-05-01T16:00:00
2SeattleSan Francisco2023-05-03T1:00:002023-05-05T6:00:00
3OrlandoBoston2023-05-05T18:00:002023-05-05T22:00:00

Input Tables

flights

Column NameData Type
idbigint
takeoff_locationtext
arrival_locationtext
plane_idbigint
flight_startdatetime
fligth_enddatetime