Dynamic Programming21 sections · 916 units
Open in Course

Challenge: Strictly Increasing

Variant with strict inequality

What if we need strictly increasing instead of non-decreasing? Transform differently. Set bi=aiib_i = a_i - i. Then aa strictly increasing iff bb non-decreasing.

But we want non-decreasing. Alternative: bi=aiiϵb_i = a_i - i \cdot \epsilon for tiny ϵ\epsilon. Conceptually, offset each position slightly. In practice: bi=aiib_i = a_i - i works for non-decreasing. For strictly increasing, use bi=aiib_i = a_i - i and require the transformed sequence to be strictly increasing (same cost structure).