9. Flood Fill
Easy

Problem Statement

Perform a flood fill on the image starting from the given pixel. (Note: Outputting modified grid to allow exact array validation against testcases).

Examples

1Example 1
Input:
[ [ [ 1, 1, 1 ], [ 1, 1, 0 ], [ 1, 0, 1 ] ], 1, 1, 2 ]
Output:
[ [ 2, 2, 2 ], [ 2, 2, 0 ], [ 2, 0, 1 ] ]
2Example 2
Input:
[ [ [ 0, 0, 0 ], [ 0, 0, 0 ] ], 0, 0, 0 ]
Output:
[ [ 0, 0, 0 ], [ 0, 0, 0 ] ]
3Example 3
Input:
[ [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], 0, 0, 2 ]
Output:
[ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ]
Loading...

Sign in to Run Code and Submit