[DAY12]Sherlock and the Valid String
Solution: In this problem, we need to think about under what circumstances can we just move a character and all the characters in the string would occur the same number of times. First, we need to record the number of occurrences of each character. But that’s still not enough, we’ll need a hash table to help us record how many characters have the same number of occurrences. If all characters have the same number of occurrences, then we don’t need to do anything.The goal is already achieved. But if there exits more than two different number of occurrences, we can never let the characters of the string have the same amount occurrences by removing only one character in the string.
Finally, we need to consider the condition when the number of occurrences only exists two different value x and b. If only one character have the number of occurrences b. And b minus x equals to one. Then all we need to do is remove an character that occurs b times. Another condition would be x is smaller than b. But x equals to 1 and only one character have the number of x. We just need to remove the character and we can achieve our goal, too.