#K94882. Check Uppercase Letters in Order
Check Uppercase Letters in Order
Check Uppercase Letters in Order
Given a string S consisting of both uppercase and lowercase English letters, determine if all the uppercase letters in the string appear in alphabetical order (i.e., from 'A' to 'Z').
If there are no uppercase letters in the string, consider the condition to be satisfied. The comparison is done based solely on the sequence of uppercase letters encountered in the string.
Note: The order is determined by the standard alphabet ordering. For example, in the string "aBcDeF", the uppercase letters are 'B', 'D', and 'F' which are in alphabetical order, so the output should be True
. In contrast, the string "aCBdEf" has uppercase letters 'C', 'B', and 'E', which are not in order (since 'B' comes before 'C'), so the output should be False
.
Mathematically, if U = (u1, u2, ..., uk) is the sequence of uppercase letters extracted from S, then the condition is satisfied if and only if \[ u_1 \le u_2 \le \cdots \le u_k \] where \(\le\) denotes the lexicographical order between letters.
inputFormat
The input consists of a single line containing the string S, which consists of only uppercase and lowercase English letters.
outputFormat
Output True
if the uppercase letters in S appear in alphabetical order, otherwise output False
.
aBcDeF
True