Search for a command to run...
Youare given a string S consisting of lowercase English letters.
You are allowed to perform at most one operation:
Select any one character
Change it to the next alphabet character
'z' changes to 'a'
After performing at most one such operation, determine whether it is possible to make all characters in the string appear the same number of times.
Return "YES" if equal frequency can be achieved
Otherwise, return "NO"
A single string S
Return "YES" if all character frequencies can be made equal after at most one operation
Otherwise return "NO"
1≤∣S∣≤1000001 \le |S| \le 1000001≤∣S∣≤100000
Input:
aabbccOutput:
YESExplanation: All characters already appear the same number of times, so no operation is needed.
Example 1
zzzzYESExample 2
abcdeNOExample 3
abcabcdddYESExample 4
aabbccdYESzzzz
YES