Codeforce round #FF: DZY loves sequences
Option 1:
len(i, lastChange, hasChange): longest strictly increasing subsegment ending at i
when we move to i + 1
len(i+1, false, false) = a[i+1] > a[i] ? len(i, false, false) : 0 + 1 len(i+1, true, true) = len(i, false, false) + 1 len(i+1, true, false) = invalid case len(i+1, false, true) = max of ( a[i+1] > a[i] ? len (i, false, true) : 0 + 1 a[i+1] > a[i-1] + 1? len(i, true, true) : 1 + 1 )
and then check all (i, bool, bool) combos for max answer base case= len(0, false,false) = 1, len(0, true, true) = 1
Option 2:
Calculate all lenEnd(i), Calculate all lenStart(i)
for all i, compute lenEnd(i) + lenStart(i), and get max
Techinique: Find all potential solutions and get the max value. This means looking at the unknown and try to infer from its properties,i.e., one out of order means we need to search based on which entry is out of order