Write 'L' on Matrix
Problem Overview
- Determine the minimum cell changes to make an odd-sized n×n matrix form an "L" of 1s: from (0,0) down the first column to the center, then across the center row to the right edge; all other cells must be 0 or 2.
- Input: n×n matrix with values in {0,1,2}; constraints: 5 ≤ n ≤ 99 and n is odd; Output: minimal change count.
- Context: matrix pattern formation relevant to data layouts or image-like masks.
- From Databricks interviews; a coding interview problem and interview question on matrix transformation.
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:
