Replacing Val

Problem Overview

  • Replace the value at a given start cell in a 2D int array and all side-connected cells that share the original value with a new value.
  • Input: matrix, start position (row, col), replacement value; Output: updated matrix; constraints unspecified.
  • Context: region filling in grid-based data like images or maps.
  • From Two_sigma interviews; a classic coding interview problem and common interview question on handling grid updates.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: