The interview puzzle with the black squares.

My algorithm:

I think a white square's value is 0.

For a black square, I get the 3 numbers on the top, top-left and left of it. Then I get the minium of the 3 numbers. And the black square's value is the minium + 1.

The answer is the biggest value of a square on the board.

评论

© 陆仁矣 | Powered by LOFTER