#K48342. Segregate Letters and Digits
Segregate Letters and Digits
Segregate Letters and Digits
This problem requires you to process a given string and segregate its alphabetic and numeric characters. Specifically, you are to output a new string that contains all the letters from the input (in the order they appear) followed by all the digits (in the order they appear). Any other characters, such as punctuation or spaces, should be ignored.
Formally, given a string s, you need to compute a result string r such that
\( r = L + D \)
where \( L \) is the concatenation of all letters in s (\( s_i \) satisfying \( s_i \in [a-zA-Z] \)) and \( D \) is the concatenation of all digits in s (\( s_i \) satisfying \( s_i \in [0-9] \)).
Maintain the relative order of the letters and digits as they appear in the input.
inputFormat
The input consists of a single line containing a string s that may include letters, digits, spaces, and other special characters.
outputFormat
Output a single line containing the modified string where all letters come first (in their original order) followed by all digits (in their original order). All other characters should be discarded.
## samplea1b2c3
abc123