# Hackerearth Balance strings Solution

## PROBLEM STATEMENT:

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

## SOURCE CODE:

`````` #include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
char arr[10000];
int a[500]={0},mx=0;
cin>>arr;
for(int i=0;arr[i]!='\0';i++){
int temp = arr[i]-97;
a[temp]++;
if(a[temp]>mx){
mx = a[temp];
}
}
int flag = 1;
for(int i=0;i<26;i++){
if(a[i]!=mx){
flag = 0;
}
}
if(flag)
{
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
return 0;
}  ``````
``````
** The above solution is my own code and it may not be the optimal solution or optimal way to approach the problem but it passes all the testcases in Hackerearth. So if you have any optimal approaches feel free to paste the code as the comment below..... :) :) :)

#### 1 comment:

1. This is a knoewledge provider blog and I always like to read these types of blogs. This blog has no econnectuon with EssayPro. As we can get the idea with the title of this blog. The title is hackerearth balance string solution. Iwould like to share this blog with many readers wwho would like to read it.