#C14079. Sort Letters While Maintaining Digit Positions

    ID: 43688 Type: Default 1000ms 256MiB

Sort Letters While Maintaining Digit Positions

Sort Letters While Maintaining Digit Positions

You are given a string s that contains a mix of alphabetic characters, digits, and possibly other special characters. Your task is to sort only the alphabetic characters (letters) in ascending order while keeping all non-alphabetic characters (digits, punctuation, etc.) in their original positions.

Formally, let \( s = s_1s_2\ldots s_n \). Define a new string \( t \) such that if \( s_i \) is a letter then it is replaced by the next letter in the sorted order of all letters in \( s \), otherwise \( s_i \) remains unchanged.

Example:

  • If s = "a1c3b2", the alphabetic characters are 'a', 'c', 'b' which when sorted become 'a', 'b', 'c'. Replacing the letters in order yields "a1b3c2".

inputFormat

The input consists of a single line containing the string s.

Note that s may include digits, letters, and special characters. Its length is between 0 and 105 characters.

outputFormat

Output the transformed string after sorting the letters while keeping the positions of non-letter characters unchanged.

## sample
a1c3b2
a1b3c2