Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- los(A)
- new vectors z1 and z2 = to A with all the values started at 1
- new var res = 1
- from i=1 to length(A) do:
- from j=0 to i do:
- if A[j] < A[i] and z1[i] < z2[j]+1:
- z1[i] = z2[j]+1
- if A[j] > A[i] and z2[i] < z1[i]+1:
- z2[i] = z1[j]+1
- if res < max(z1[i],z2[i])
- res = max(z1[i],z2[i])
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement