LeetCode
Flood Fill
Click
here
for an explanation.