Balance strings, by definition, are the strings that contain all the characters of the…
- User
Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times. eg- abcdefghijklmnopqrstuvwxyz is a balanced string, aabb is not. Input: First line contains number of test cases T. Each test case contains a string S which made up of only lowercase characters.
Output: For each test case print Yes if the string is balanced string else print No.
Constraints: 1 ≤ T ≤ 10 1 ≤ |S| ≤ 1000
SAMPLE INPUT 2 codemyca abcdefghijklmnopqrstuvwxyz
SAMPLE OUTPUT No Yes
Assistant
pythonfrom collections import Counter t = int(input()) for _ in range(t): s = input().strip() if len(s) % 26 != 0: print("No") else: req = len(s) // 26 cnt = Counter(s) if len(cnt) != 26: print("No") else: valid = True for count in cnt.values(): if count != req: valid = False break print("Yes" if valid else "No")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.