Build an Undirected Graph and Traverse with DFS
Asked at Google DeepMind · Coding Questions · Difficulty: Easy · Last asked Jun 18, 2026
You are given the edges of an undirected graph as a list of node pairs. Build the graph and return the order in which a depth-first search (DFS) from a given start node first visits each node. To make the answer unique, the search always goes to the smallest unvisited neighbour first.
Loading the problem…
More Google DeepMind interview questions
- LLM conceptual questions
- Classify a Float Into One of Two Arrays
- Calculus and Probability Fundamentals for ML
- Fundamentals Toolkit for ML: Functional Programming, NP-Completeness, Calculus, Entropy, MGFs, Insertion Sort, CLT
- Matrix Diagonals Listed in Order
- Generate a Random Number Given Probability Distribution