Regulatory action sequence

Dynamic programming sequence

A. On the longest rise / fall / rise does / does not drop sequence

Such an algorithm example


  Note: the following algorithm chosen by the longest sequence showing the rise      

  1. (n 2 )

     Thinking: f [i] represented by q [i] at the end of the longest sub-sequence length increase, an initial value. Per cycle 1 ~ n, recirculation 1 ~ i - 1, if q [i]> q [j] (ah to rise), it is f [i] = max (f [i], f [j] + 1 ) (this is because the 1 + plus q [i] ah)

Guess you like

Origin www.cnblogs.com/qqq1112/p/11129423.html