1288. Invert Case of All Characters in a String

EasyBit ManipulationBit ManipulationASCIIString

Given a string, invert the case of every English letter (uppercase becomes lowercase and vice versa) while leaving all other characters unchanged. Toggle case with an XOR of 32 on letter codes.

Input: A JSON object {"s": <string>} containing printable ASCII characters.

Output: Return the case-inverted string.

Examples

Example 1
Input: {"s":"Hello, World!"}
Output: hELLO, wORLD!
Explanation: Each letter flips case; punctuation stays -> 'hELLO, wORLD!'.
Example 2
Input: {"s":"abcXYZ"}
Output: ABCxyz
Explanation: Lower becomes upper and upper becomes lower -> 'ABCxyz'.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →