Wednesday, April 23, 2014

DP --- Longest Non-decreasing Subsequence

1. Find the longest alternating subsequence
   ai < ai+1 for even i, ai > ai+1 for odd i

   can still use the record the longest sequence method, just need to pay attention where to put the new element

2. Define a sequence of points in the plane to be ascending if each point is above and to the right of the previous point. How would you find a maximum ascending subset of a set of points in the plane?
First map them to the x-axis, then get the height of each point sqrt(x^2+y^2) , then do the same non-decreasing subsequence

No comments:

Post a Comment