Algorithm · Capital One · Medium
Requirements Input: an integer grid with n rows and m columns, where every entry represents a color. Function signature: def transform(grid: List[List[int]]) -> List[List[int]]. A position (r, c) must be selected for deletion when at least two of its valid orthogonal neighbors—above, below, left, or right—have the identical color. First determine every cell that meets the condition, then delete all selected cells at once. Do not let deletions affect checks during that scan;…
Checking your access…