Problem statement: You are a given a string s , int x and int y; S consists of three characters '0', '1', and '?' You can replace '?' with either '0' or '1'. You need to minimize the following equation:
Equation is a*x + b*y.
Here a is the number of "01" subsequences and b is number of "10" subsequences after the replacement of all '?'
Constraints
I was thinking in direction of DP and making it run in nlogn and some sort of convex hull emerges in my head but I don't have enough practice to make it work. Any idea folks?