#K43297. Flip Case and Reverse
Flip Case and Reverse
Flip Case and Reverse
You are given a string S. Your task is to flip the case of each alphabetical character in the string and then reverse the entire string.
The transformation should be done as follows:
- If a character is in lowercase, convert it to uppercase.
- If a character is in uppercase, convert it to lowercase.
- Non-alphabetical characters remain unchanged.
After flipping the case of every character, the resulting string should be reversed. Mathematically, if the transformation is denoted by \( f(S) \), then:
\[ f(S) = \text{reverse}(\text{flip}(S)) \]For example, given the input Hello World!
, the output should be !DLROw OLLEh
.
inputFormat
The input consists of a single line that contains a non-empty string S. The string may include alphabets, digits, and special characters.
outputFormat
Output a single line containing the resultant string after flipping the case of each character and then reversing the string.
## sampleHello World!
!DLROw OLLEh