837. Change Case of Each Character in a String
Given a string s, write a program to invert the case of each character:
- Convert lowercase letters to uppercase
- Convert uppercase letters to lowercase
- Leave non-alphabetic characters unchanged
Example 1:
Input: s = "javA"
Output: "JAVa"
Explanation: j → J, a → A, v → V, A → a
Example 2:
Input: s = "take u forward IS Awesome"
Output: "TAKE U FORWARD is aWESOME"
Explanation: All alphabet cases inverted; spaces preserved
Now Your Turn!
Pick the correct output for the given inputInput: s = ""
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
0 <= s.length <= 105
The string may contain:
- lowercase & uppercase English letters
- spaces, digits, and special characters