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
pythonimport sys from collections import Counter T = int(sys.stdin.readline()) for _ in range(T): S = sys.stdin.readline().strip() n = len(S) if n % 26 != 0: print("No") continue k = n // 26 cnt = Counter(S) if len(cnt) != 26: print("No") continue valid = True for count in cnt.values(): if count != k: 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.