Reconstruct Itinerary

Hard
Graphs Euler Path DFS
Solve Reconstruct Itinerary. Input/Output: as specified in examples.

Constraints

Optimized solution required.

Examples

Example 1:
Input: sample
Output:
Example 2:
Input: test
Output:

Hints

Consider a euler path based approach.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.