#SDNU1724. Commencement
Commencement
Problem Statement
A string consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers not less than 1:
- There are exactly zero or exactly two different letters that appear exactly ii times in .
Given a string , determine if it is a good string.
Constraints
- is a string of lowercase English letters with a length between and , inclusive.
Input
The input is given from Standard Input in the following format:
S
Output
Print Yes if SS is a good string, and No otherwise.
commencement
Yes
For the string commencement, the number of different letters that appear exactly iitimes is as follows:
- i=1: two letters (
oandt) - i=2: two letters (
candn) - i=3: two letters (
eandm) - i≥4: zero letters
Therefore, commencement satisfies the condition of a good string.
banana
No
For the string banana, there is only one letter that appears exactly one time, which is b, so it does not satisfy the condition of a good string.
ab
Yes