Interview questions · MathWorks
Determine Whether P's Position Is Unique
This question evaluates constraint-satisfaction and combinatorial search skills, specifically reasoning about spatial relations and whether a target's location is uniquely determined among all valid assignments on a discrete grid.
You are given an R x C rectangular grid and a set of named entities. Each entity must be placed in exactly one distinct cell.
You are also given a collection of relational clues describing how the entities may be positioned relative to one another. Examples of such clues include constraints like being in the same row, same column, left/right of another entity, or above/below another entity.
Implement a function that determines whether the location of a particular target person P is uniquely determined by all valid placements that satisfy every clue.
Return the unique coordinate (row, column) of P if exactly one valid assignment places P in a single location. Otherwise, report that no unique solution exists.
Assume rows and columns are 1-indexed.
Community answers
Nothing here yet.
Join in on CSWork →