Problem Statement
Your task is, given a String typed by Typo, recover the original String. Assume that the original text has only letters, commas, periods and spaces. For examples, if he types ':' it means that he meant to type the space (' ') and the previous letter is shifted. Assume, that the last character of the original String doesn't require the Shift button (i.e. it is either a lower case letter [a-z], a comma, a period, or a space character.
Definition
- Class:
- Case
- Method:
- recover
- Parameters:
- String
- Returns:
- String
- Method signature:
- String recover(String text)
- (be sure your method is public)
Notes
- If you hold down shift and press space, you still get a space. In other words, shift does not effect the space character.
Constraints
- text will consist only of letters [A-Z] and [a-z] inclusive, and the following characters: .,:;<>
- text will have between 0 and 50 characters inclusive
- if text has at least one character, then the first character will be a lower-case letter [a-z] or one of ',', '.' or ';' (as Typo never presses the Shift button for the first character)
Examples
"tOpcOder"
Returns: "TopCoder"
The two 'O's are capitalized, but that is with the shift character delayed."uSA<;and;rUssia"
Returns: "USA, and Russia"
Note that '<' is a shifted comma."nEw;yOrk;;;aND:;;bOston"
Returns: "New York AND Boston"
Here, a ':' occurs where a ';' is shifted.""
Returns: ""
";A"
Returns: " a"
Note that a shifted space is still a space.