Last active
July 23, 2017 05:36
-
-
Save nerohoop/79f94cae3042b51db33f65bf55b21efd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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