title: How to print Longest Increasing Subsequence(LIS) from a given array?
body: <p>I can print the length of a LIS by a normal function and Recursive function. But I want to print that index of LIS subsequence in a given array in C++.</p>
  
  <p>Here is my function to find the length of LIS : </p>
  
  <pre><code>int lis( int *arr, int n )
  {
     int *lis, i, j, max = 0;
     lis = (int*) malloc ( sizeof( int ) * n );
     for ( i = 0; i &lt; n; i++ )
        lis[i] = 1;
     for ( i = 1; i &lt; n; i++ )
        for ( j = 0; j &lt; i; j++ )
           if ( arr[i] &gt; arr[j] &amp;&amp; lis[i] &lt; lis[j] + 1)
              lis[i] = lis[j] + 1;
     for ( i = 0; i &lt; n; i++ )
        if ( max &lt; lis[i] )
           max = lis[i];
     /* Free memory to avoid memory leak */
     free( lis );
     return max;
  }
  </code></pre>
  
  <p>here <code>array[10]={7 6 2 3 4 1 8 5 9 10}</code></p>
  
  <p>here <code>LIS Length=6</code></p>
  
  <p>I wanna print the index of numbers <code>{2 3 4 6 8 9}</code> ( its not the sequence its the arrray index , what i wanna print ) index of sequence in the <code>array[10]</code></p>