Editorial for DMOPC '18 Contest 6 P1 - DNA or RNA?
Submitting an official solution before solving the problem yourself is a bannable offence.
Firstly, check if the string contains any letter that is not
U. If this is true, it is neither DNA nor RNA.
Then, check for the presence of a
T and a
U in the string. If only
T is present, it is DNA. If only
U is present, it is RNA. If neither are present, it could be either DNA or RNA. Finally, if both are present, it is neither DNA nor RNA.
Interesting fact: in reality, DNA can contain uracil and RNA can contain thymine on rare occasions.