You can try to visualize this. For example:
“`
ooooo
oooo xxxxo
ooo xxxo xxxxo
oo xxo xxxo xxxxo
xo xxo xxxo xxxxo
“`
If you think of Xs as the previous square and the Os as what you need to add to get the new square, you’ll see it’s the length of the old square plus the height of the old square plus 1. This is where the 2N+1 that others have mentioned comes from.
Latest Answers