I will be disappointed if your first efficiency fix isn't reduction of the matrix to current row and row above. None of the rows above these two matter at any given time. Great post, thanks! I now really want to play with this using long strings with whole words added in the middle.
I don't want to spoil anything but... yep, that is the first major memory optimization.
With your specific example though, I think you will like one or two of the other performance improvements more. 🙂
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.