Problem Statement
Class name: MinMove Method name: determineMinSwaps parameters: String, String Returns: int Given a String, and a scrambled version of the String with an extra space, determine the number of character swaps necessary to unscramble the String. Characters may only be swapped with the blank space. When unscrambling the String, the space must end up as the last character of the String. For example, given "abc","c ba", the scrambled String undergoes the following swaps: swap(1,2) -> "cb a" swap(0,2) -> " bca" swap(0,3) -> "abc " The String is now unscrambled, and since it took 3 swaps, return value is 3. Here is the method signature (be sure your method is public): int determineMinSwaps(String unscrambled,String scrambled); The second String must be exactly one character longer than the first, and contain exactly one space. Each String will contain only lowercase letters, except for the second one, which will contain the space. The space in the second String may be anywhere. The first String will be less than or equal 10 characters in length and at least one character in length. Other than the space, the first and second String will contain the same numbers of the same characters. Examples: "farmerfred", "armerfred f" retrns 10. "greeneggs","rgnegs gee" returns 7. "what","what " returns 0. "topcoder"," oecrdpot" returns 7.
Definition
- Class:
- MinMove
- Method:
- determineMinSwaps
- Parameters:
- String, String
- Returns:
- int
- Method signature:
- int determineMinSwaps(String param0, String param1)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.