/* Assume inp is the given array*/
static int bitmap[N][N];
int lengths[N];
int currentBitmap = -1;
int active = 1;
int lastPos;
for(i=0;i<N;i++)
{
  if(inp[i]==1)
  {
   currentBitmap++;
   active=1;
   lastPos=i;
  }
  if(active==1)
  {
   if(bitmap[currentBitmap][inp[i]]==1)
   {
    active=0;
    lengths[currentBitmap]=(i-pos);
   }
   else
   bitmap[currentBitmap][inp[i]]=1;
  }
}
pos = findMax(lengths);
print(lengths[pos]);

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to