I’m reading the solution for the 2012 old silver problem Landscaping.
I’m not quite getting some of the logic of the dp solution. I get everything up to this point:
three possible operations: insertion ..., deletion ..., or modification of a character (at cost Z times the magnitude of the change).
I get the insertion and deletion parts. For modification, how are we able to guarantee that there is enough dirt in flowerbed 1, in the position that we are at in flowerbed 2?
For example, if we had a 1 at (position i, flowerbed 1) and a 2 at (position j, flowerbed 2) how do we know if there is also dirt at position 2 in flowerbed 1?