Flood-fill (1-d dp)

i did not understand , how to fill color of square, please help me