Determine Whether P's Position Is Unique

Quick Overview

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.

Determine Whether P's Position Is Unique

Company: MathWorks

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

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.

Overview: 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.

|Home/Coding & Algorithms/MathWorks
MathWorks logo
MathWorks
Jan 22, 2026
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
6
0

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.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...