| ||A palindrome is a string that reads the same from left to right as it does from right to left.
You are given a String s. The length of s is even. Each character of s is either 'o', 'x', or '?'
Your task in this problem is to replace each occurrence of '?' in s with either 'o' or 'x' so that s becomes a palindrome.
You are also given ints oCost and xCost.
Replacing '?' with 'o' costs oCost, and replacing '?' with 'x' costs xCost.
Return the minimum cost of replacing '?'s by 'x's and 'o's that turns s into a palindrome. If it is impossible to obtain a palindrome, return -1 instead.|
|Parameters:||String, int, int|
|Method signature:||int getMinimum(String s, int oCost, int xCost)|
|(be sure your method is public)|
|-||You are not allowed to change an 'x' into an 'o' or vice versa.|
|-||s will contain between 2 and 20 characters, inclusive.|
|-||The length of s will be even.|
|-||Each character of s will be either 'o' or 'x' or '?'.|
|-||oCost will be between 1 and 50, inclusive.|
|-||xCost will be between 1 and 50, inclusive.|
|The only way to produce a palindrome is to replace s with 'x' and s with 'o'. The first replacement costs 5, the second costs 3, so the total cost is 3+5=8.|
|There are two ways to produce a palindrome here. The cheaper one is to change both '?'s to 'x's. This costs 4+4=8. Note that you are required to replace all '?'s.|
|There is no '?' character, and s is not a palindrome. We have no way to change it into a palindrome.|
|There is no '?' character, and s is already a palindrome. Making no replacements does not cost anything.|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.