Shortest Drone Walk That Visits Every Delivery Drop Point

Last updated: November 29, 2026

Quick Overview

A Prime Air drone flies along an undirected graph of n drop points (n up to 12), where each edge is one hop. Return the fewest hops in a walk that visits every node at least once, starting and ending anywhere, with revisits allowed.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A Prime Air drone flies along an undirected graph of n drop points (n up to 12), where each edge is one hop. Return the fewest hops in a walk that visits every node at least once, starting and ending anywhere, with revisits allowed.

An Amazon onsite hard question that combines BFS with bitmask state. The interviewer wants you to see that the state is (current node, set of visited nodes), to start BFS from every node at once, and to reason about the 2^n * n state space.

What the Interviewer Expects
  • Models state as (node, visited mask)
  • Runs multi-source BFS from every node
  • Stops at the first state whose mask is full
  • Bounds the state space at n * 2^n
  • Handles n = 1
Key Topics to Cover
bitmask BFS
state space search
graph traversal
multi-source BFS
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if edges have different flight times?
  • Require the walk to return to the start node.
  • How large can n get before this approach stops being practical?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: adjacency list graph where graph[i] lists neighbors of i; the graph is connected and n <= 12. Output: minimum number of edges in a walk that touches every node. Nodes and edges may repeat....

High-Level Design

Because revisiting is allowed, plain BFS over nodes is not enough: the same node at different points of the walk is a different situation depending on what has been visited. The state is (node, mask) ...


Submit Your Answer
Markdown supported