Last active
March 7, 2019 16:00
-
-
Save tchomphoochan/391dcdd9c4bba845fbfda9c8d89046f5 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
int A[MAX_N]; // assume data is in A[1..n] | |
int dp[MAX_N]; | |
int ans = 0; | |
for (int i = 1; i <= n; ++i) { | |
dp[i] = 1; | |
for (int j = 1; j < i; ++j) { | |
if (A[j] < A[i]) | |
dp[i] = max(dp[i], 1+dp[j]); | |
} | |
ans = max(ans, dp[i]); | |
} | |
cout << ans << endl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment