Back to problems

Min Errors in 0/1/! Subsequence DP

Algorithm · Amazon · Hard

Requirements You are given a string s whose characters come from {0, 1, !}, along with two positive costs x and y. Every ! must independently be replaced by either 0 or 1. For the resulting binary string, calculate x times the number of 01 subsequences plus y times the number of 10 subsequences. Return the smallest total cost obtainable by choosing replacements for all ! characters. Examples

Checking your access…