Thursday, January 21, 2010

Longest non decreasing sequence.

Given a sequence of N numbers. Find the length of the longest non-decreasing sequence.

1 comment:

  1. global_max=0; this_max=0; for (i=1 to n-1) if (x[i]>=x[i-1]) { this_max++; global_max=max(this_max, global_max);} else this_max=0;

    ReplyDelete