Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 1; i < n; ++i) {
- if (a[i] == a[i - 1]) dp[i][0] = dp[i-1][1] + 1, dp[i][1] = dp[i-1][0] + 1;
- else if (a[i] == a[i - 1] + 1) dp[i][0] = dp[i-1][0], dp[i][1] = min(dp[i-1][0], dp[i-1][1]) + 1;
- else if (a[i] + 1 == a[i - 1]) dp[i][0] = min(dp[i-1][0], dp[i-1][1]), dp[i][1] = dp[i-1][1] + 1;
- else dp[i][0] = min(dp[i-1][0], dp[i-1][1]), dp[i][1] = dp[i][0] + 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement