Created
June 7, 2023 16:18
-
-
Save Eunoia1729/3e0d292fb87f76975afcf21f90452122 to your computer and use it in GitHub Desktop.
three jumps
This file contains hidden or 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 test() { | |
// initalize dp[i][0] with 1 | |
// dp[index][jumps_used] | |
result = 0; | |
for(int i = 0; i < n; ++i) { | |
for(int j = 0; j <= 3; ++j) { | |
for(int k = 1; k <= 3; ++k) { | |
if( i - k >= 0 and v[i] == v[i - k] and j - k >= 0) { | |
dp[i][j] = max(dp[i][j], 1 + k + dp[i - k][j - k)]); | |
} | |
if( j + 1 == k) { | |
dp[i][j] = max(dp[i][j], k); | |
} | |
} | |
result = max(result, dp[i][j]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment