My first instinct was just Dijkstra from A and call it a day.
Model the flights as a directed weighted graph where cities are nodes and flights are edges with prices as weights. The problem reduces to finding the shortest cycle through city A, which can be solved by running Dijkstra from A to all nodes, then from all nodes to A on the reversed graph, and taking the minimum sum of distances for any node B (where B ≠ A).
Pro tip: Clarify whether the round-trip must use distinct outbound and return flights (i.e., no reusing the same flight) and whether multiple flights between the same cities are allowed. This shows attention to edge cases and prevents incorrect assumptions.
Ask about graph properties: directed/undirected, positive weights, possible multiple edges, and whether the trip must consist of two distinct flights. Confirm that the goal is to minimize total cost.
Represent cities as nodes and flights as directed edges with weights equal to prices. The round-trip is a cycle that starts and ends at A, possibly visiting other cities.
Use Dijkstra's algorithm to compute shortest paths from A to all nodes, and from all nodes to A by running Dijkstra on the reversed graph. Alternatively, consider Floyd-Warshall if the graph is small.
For each city B ≠ A, sum the shortest distance from A to B and from B to A. The minimum over all B is the answer. If no such B exists, return -1 or indicate impossibility.
Discuss time complexity (O(E log V) with Dijkstra) and handle edge cases: no path, direct round-trip A→B→A, and potential negative weights (though prices are positive).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.