Skip to content

Instantly share code, notes, and snippets.

@nerohoop
Last active July 23, 2017 05:36
Show Gist options
  • Save nerohoop/79f94cae3042b51db33f65bf55b21efd to your computer and use it in GitHub Desktop.
Save nerohoop/79f94cae3042b51db33f65bf55b21efd to your computer and use it in GitHub Desktop.
/* Initialize LIS values for all indexes */
for (i = 0; i < n; i++ )
lis[i] = 1;
/* Compute optimized LIS values in bottom up manner */
for (i = 1; i < n; i++ )
for (j = 0; j < i; j++ )
if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)
lis[i] = lis[j] + 1;
/* Pick maximum of all LIS values */
for (i = 0; i < n; i++ )
if (max < lis[i])
max = lis[i];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment