Count Inspection Routes That Cover Every Open Data Center Tile

Last updated: November 29, 2026

Quick Overview

An inspection drone starts on the start tile (1) and must end on the end tile (2), moving up, down, left or right, stepping on every open tile (0) exactly once and never on blocked tiles (-1). Count the number of such routes.

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

0

0

0 solved


An inspection drone starts on the start tile (1) and must end on the end tile (2), moving up, down, left or right, stepping on every open tile (0) exactly once and never on blocked tiles (-1). Count the number of such routes.

Meta data center operations automate floor inspections, and this question checks exhaustive grid backtracking with visit-every-cell constraints. The interviewer looks for in-place visited marking, a correct remaining-cell count, and a clear statement of exponential cost.

What the Interviewer Expects
  • Count the cells that must be visited, including start and end
  • Mark cells visited in place and restore them
  • Only accept the end tile when all other cells are used
  • Explain why DP on position alone is insufficient
  • Discuss the bitmask DP alternative for small grids
Key Topics to Cover
Backtracking
Grid DFS
Hamiltonian path
Bitmask DP
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
  • How would you speed this up with memoization over (cell, visited mask)?
  • How would you return one route instead of a count?
  • How would you prune using connectivity of the unvisited cells?
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
  • Grid up to 20 cells, exactly one start and one end.
  • A route visits every non-blocked cell exactly once.
  • Return the number of routes....
High-Level Design

Count all non-blocked cells; that is the exact number of steps (cells) a valid route covers. DFS from the start, carrying remaining, the cells still to step on including the current one. When we rea...


Submit Your Answer
Markdown supported