You are given two strings S and T of the same length. S consists of the characters 0, 1 and ?, and T consists of 0 and 1 only. Convert S into T using as few moves as possible. One move is one of the following:
- change a
0 in S to 1
- change a
? in S to 0 or 1
- swap two characters of S
No move turns a 1 back into a 0.
For example, take S= 01??00 and T= 001010. Three moves are enough:
- at the start S=
01??00
- move 1 changes the third character to
1, so S= 011?00
- move 2 changes the fourth character to
0, so S= 011000
- move 3 swaps the second character with the fifth character, so S=
001010