9/40
Part 2 of 7 · Two statesLearn
One number per position forgets whether the deletion is spent
A table can beat trying every deletion, but the first table to try is wrong.
kept 4·568·910
The first table to try keeps one number per position: the longest run ending at a[i], with or without a deletion. At the 8 that's 4, the run 4, 5, 6, 8 with the 7 deleted. Delete the 3 too, and that run goes on as 4, 5, 6, 8, 9, 10, so this table says 6.
But that answer deleted two elements. The number at each position forgot whether its run had already spent the deletion. And the deletion is exactly what the next step needs to know.