Let w be a string consisting of lowercase letters. We will call w beautiful if the…
- User
Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied:
- Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is beautiful.
Constraints
- 1 \leq |w| \leq 100
- w consists of lowercase letters (
a-z). Input
The input is given from Standard Input in the following format:
w
Output
Print
Yesif w is beautiful. PrintNootherwise.Examples
Input
abaccaba
Output
Yes
Input
hthth
Output
No
Assistant
We need to parse the problem: given a string w, we need to check if each lowercase letter appears an even number of times. Output Yes if all counts are even, else No. Simple.
Constraints small.
Edge cases: empty string? but |w| >= 1. So at least one character.
Implementation: count frequency of each letter; iterate over counts; if any is odd, output No; else Yes.
In Python:
import sys
def main(): w = sys.stdin.readline().strip() counts = [0]*26 for ch in w: counts[ord(ch)-97] += 1 for c in counts: if c%2 == 1: print("No") return print("Yes")
if name == "main": main()
That solves.
But note: the problem description states "each lowercase letter of the English alphabet occurs even number of times in w". That means letters not present count as 0, which is even. So only need to check counts of letters that appear? Actually 0 is even, so it's fine. So we just check all 26.