In O(n^2)
eg.
#include
#include
using namespace std;
int a[]={9,8,10,15,6,22,23,4,111,112};
int p[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
int m[10];
int main()
{
int max, pos, i,j;
for(i=9; i>=0; i--)
{
for(j=i+1; j<10; j++)
{
if(a[i]http://groups.google.com/
Subsequence need not be consecutive numbers. A subsequence of
{1,3,7,2,5,8,10,4,6,11} is {1,3,7,8,10,11}.
On Sep 6, 4:14 pm, Ashim Kapoor wrote:
> int a[]={11,9,8,2,10,7,3,4,5}
> max_length = 1 ;
> current_length = 1;
> first_position=0 ;
> last_position = 0 ;
> first_position_max=0;
> // Sweep