Toggle Character Case
You are given a single character ch. Your task is to toggle its case:
- Convert an uppercase English letter to lowercase.
- Convert a lowercase English letter to uppercase.
- Leave all other characters unchanged, including digits and special characters.
Return the resulting character.
Example 1:
Input:
ch = 'A'
Output:
a
Explanation:
The character 'A' is an uppercase English letter. Toggling its case converts it to the lowercase character 'a'.
Example 2:
Input:
ch = '#'
Output:
#
Explanation:
The character '#' is a special character, not an uppercase or lowercase letter. Therefore, it remains unchanged.
Now Your Turn!
Pick the correct output for the given inputInput:
ch = 'z'
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- ch is a printable ASCII character.