The interview problem

Practice prompt

Build a tool that fills a user-selected damaged region while preserving every unmasked pixel.

Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.

1. Scope and worked approach

Require an explicit mask, keep the source immutable and composite the candidate only within the authorized region. Begin with a conventional inpainting baseline for small scratches; route large semantic fills to a separately evaluated model and label them as generated content.

2. Trace the design or derivation

Source and mask
  → fill candidate
  → mask composite
  → preservation check
  → export

Use lossless export when exact outside-mask preservation is contractual. Evaluate edge seams and user acceptance separately from reconstruction error on artificially removed regions; those artificial cases do not prove correctness when the original content is unknown.

3. Calculate the example

A 1000×1000 image with a 100×100 repair mask allows changes in 10,000 of 1,000,000 pixels, or 1%. A pixel-difference check outside that mask should find zero changes before encoding effects.

4. Failure cases and trade-offs

A plausible fill is not recovery of historical truth. JPEG re-encoding can alter nominally untouched pixels, so define whether the preservation guarantee applies to the decoded buffer or final file.

5. Validation, follow-ups and self-review

Test mask boundaries, empty masks and oversized fills. Follow-up: how does archival use change the UI? Self-review: state the preservation contract and uncertainty of generated details.

Sources and related practice

Technical reference: docs.opencv.org — Mask-based classical image inpainting.

Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.

Continue with Restore scanned images without inventing evidence; Gate low-quality uploads before downstream inference.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.