← Spotnana Interview Insights

Spotnana·Software Engineer·Technical Phone Screen·Junior

JuniorPending
Jul 2026

Summary

Spotnana SDE 1 backend interview with two interviewers, one of whom threw a hard graph problem at me that I was completely unprepared for. Came up with the right approach but couldn't finish coding it, so I'm not holding my breath on the result.

Questions Asked (1)

Q1

Given a list of airline tickets represented as pairs of departure and arrival airports, reconstruct the itinerary in order. The itinerary must begin with a specific starting airport and use all tickets exactly once. (LeetCode 332 - Reconstruct Itinerary)

Algorithms & Data Structures
Author's notes

I had a rough idea of the approach, Eulerian path with a stack and adjacency list sorted lexicographically, and explained it well enough that they seemed to follow.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the tickets as a directed graph and use Hierholzer's algorithm to find an Eulerian path starting from the given airport. Perform a post-order DFS, adding airports to the itinerary after exploring all outgoing edges, then reverse the result to get the correct order.

Pro tip: Mention that using a min-heap for each airport's destinations ensures lexical order, and that the algorithm runs in O(E log E) time due to sorting, which is efficient for typical input sizes.

1. Understand the problem

Clarify that we need to use all tickets exactly once, forming a valid sequence starting from a given airport. Recognize this as finding an Eulerian path in a directed graph.

2. Build the graph

Create an adjacency list where each departure airport maps to a min-heap (or sorted list) of arrival airports to ensure lexical order when multiple choices exist.

3. Apply Hierholzer's algorithm

Perform a DFS from the starting airport, recursively visiting destinations. After exploring all outgoing edges from an airport, add it to the itinerary (post-order).

4. Reverse the itinerary

Since the post-order DFS adds airports in reverse order, reverse the collected list to obtain the correct itinerary from start to end.

5. Analyze complexity and edge cases

Discuss time complexity O(E log E) due to heap operations, and space O(E). Mention edge cases like multiple valid itineraries (lexical order required) and disconnected graphs (though problem guarantees a valid path).

Key Points to Mention

  • Eulerian path concept and conditions (all vertices with non-zero degree belong to a single connected component, and at most one vertex has out-degree - in-degree = 1, etc.)
  • Hierholzer's algorithm for finding Eulerian paths
  • Using a min-heap or sorted list to maintain lexical order
  • Post-order DFS and reversing the result
  • Time and space complexity analysis
  • Handling of duplicate tickets and ensuring each ticket is used exactly once

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.