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() n = len(s) if n % 26 != 0: print("No") else: required = n // 26 cnt = Counter(s) balanced = True for c in 'abcdefghijklmnopqrstuvwxyz': if cnt.get(c, 0) != required: balanced = False break print("Yes" if balanced 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.