30. Flood Fill Code
Easy

Problem Statement

Perform a flood fill on an image starting from a given pixel modifying it to the specified color. Returns the modified image grid.

Examples

1Example 1
Input:
{ "image": [ [ 1, 1, 1 ], [ 1, 1, 0 ], [ 1, 0, 1 ] ], "sr": 1, "sc": 1, "color": 2 }
Output:
[ [ 2, 2, 2 ], [ 2, 2, 0 ], [ 2, 0, 1 ] ]
2Example 2
Input:
{ "image": [ [ 0, 0, 0 ], [ 0, 0, 0 ] ], "sr": 0, "sc": 0, "color": 0 }
Output:
[ [ 0, 0, 0 ], [ 0, 0, 0 ] ]
3Example 3
Input:
{ "image": [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], "sr": 0, "sc": 0, "color": 2 }
Output:
[ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ]
Loading...

Sign in to Run Code and Submit

    30. Flood Fill Code – DSA Problem Solution | DSAPrime