1005. Remove Characters Except Alphabets
Given a string str, write a program to remove all characters from the string except alphabet letters (both lowercase and uppercase). Preserve the order of the alphabets.
Example 1:
Input:Â str = "take12% *&u ^$#forward"
Output: takeuforward
Explanation:
- Characters like 1,2,%,*,&,^,$,# and whitespaces are removed.
- Only alphabets remain in original order.
Example 2:
Input: str = "1.Python & 2.Java"
Output: PythonJava
Explanation:
- All non-alphabet characters are removed.
- Only alphabetic characters remain.
Now Your Turn!
Pick the correct output for the given inputInput: str = "1234!@#$"
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= str.length <= 1000
- str contains printable ASCII characters.
- Output should preserve the order of alphabetic characters.