Skip to content

Instantly share code, notes, and snippets.

@Eunoia1729
Created June 7, 2023 16:18
Show Gist options
  • Save Eunoia1729/3e0d292fb87f76975afcf21f90452122 to your computer and use it in GitHub Desktop.
Save Eunoia1729/3e0d292fb87f76975afcf21f90452122 to your computer and use it in GitHub Desktop.
three jumps
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