Description
6. Flight Itinerary Planner

Given a list of flight itineraries, each represented as a pair of departure and arrival airports, write a function to compute the user's possible itinerary starting from a given departure airport. The itinerary must use all the flights in the list exactly once. If no such itinerary is possible, the function should return null. If there are multiple possible itineraries, return any one of them.

Example 1

Input:  [[["MUC", "LHR"], ["JFK", "MUC"], ["SFO", "SJC"], ["LHR", "SFO"]], "JFK"]
Output: ["JFK", "MUC", "LHR", "SFO", "SJC"] or any valid itinerary

Example 2

Input:  [[["JFK","KUL"],["JFK","NRT"],["NRT","JFK"]], "JFK"]
Output: null, since there's no way to use all flights exactly once starting from JFK

Example 3

Input:  [[["ATL","EWR"],["SFO","ATL"],["EWR","SFO"]], "ATL"]
Output: ["ATL", "EWR", "SFO", "ATL"] or any valid itinerary
Constraints:
    • 1 <= flights.length <= 300
    • Each airport code consists of exactly 3 capital letters.
    • The flights array does not contain duplicate flights.
Test Cases

Case 1
Case 2
Case 3

Input

[[["MUC", "LHR"], ["JFK", "MUC"], ["SFO", "SJC"], ["LHR", "SFO"]], "JFK"]

Output

["JFK", "MUC", "LHR", "SFO", "SJC"] or any valid itinerary