Suppose there is a n*n bitmap. Each of the pixel in bitmap can only be black or white, and initially they are all white.
Someone is coloring the bitmap one pixel each time.
Our goal is to get the maximum number of connected pixels in that bitmap, each time after someone colored a pixel.
The connected pixel is 4-pixel (north, west, east, south) instead of 8-pixel (all the pixels around).
How to design an algorithm with least amortized cost and worst-case running time?