I had an interview today and I was asked this question!
code the MS Paint program. Region N * N pixels. given pixel and color, change the color in the pixel to the desired color, and if neighboring pixels have the same color, change them too.
i came up to him, saying that I would take an n * n array and check for a given pixel and move to the next one. for example, the given pixel is x, yi will first check the color in x, y in the array and the next search (x + 1, y + 1), (x + 1, y), (x, y + 1), (x- 1, y), (x-1, Y-1) ....
but the interviewer was not happy, can someone suggest me another way with the best algorithm, which has the best spatial and temporal complexity!
algorithm
helpme
source share