Skip to main content
Practice

coding-quiz-8

---
id: coding-quiz-8
title: Coding Quiz - Finding Travel Routes
description: Write a function to find possible travel routes using the given flight tickets by utilizing graph traversal algorithms.
tags:
- Python
- Graph Traversal
- DFS
- Algorithms
- Functions
sidebar_position: 15
isPublic: false
---

# Coding Quiz - Finding Travel Routes

In this coding problem, you will write a function to find possible travel routes using the given flight tickets by utilizing a `graph traversal algorithm`.

You are provided with several flight tickets, and each ticket contains a departure city and a destination city.

Your goal is to list the sequence of cities visited using all the tickets.

If there are `multiple possible routes`, you should choose the route that is `alphabetically first`.

<br />

```python title="Write Code"
def solution(tickets):
# Write your code here
return



Constraints

  • Each ticket must be used exactly once.

  • The route must start at 'ICN' airport.

  • The number of given tickets ranges from 1 to 10,000.

  • Each ticket's departure and arrival are represented by a 3-letter uppercase alphabet code.




Input/Output Example

  • Input: [["ICN", "JFK"], ["HND", "IAD"], ["JFK", "HND"]]
  • Output: ["ICN", "JFK", "HND", "IAD"]



Explanation

  • Using the given tickets, the possible route is "ICN" -> "JFK" -> "HND" -> "IAD".

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.