# [TCS] Super ASCII String Checker (CodeVita) Problem [Solved]

Problem : Super ASCII String Checker
In the Byteland country a string "S" is said to super ascii string if and only if count of each character in the string is equal to its ascii value.

In the Byteland country ascii code of 'a' is 1, 'b' is 2 ...'z' is 26.

Your task is to find out whether the given string is a super ascii string or not.

Input Format:

First line contains number of test cases T, followed by T lines, each containing a string "S".

Output Format:

For each test case print "Yes" if the String "S" is super ascii, else print "No"
Constraints:

1<=T<=100
1<=|S|<=400, S will contains only lower case alphabets ('a'-'z').

Sample Input and Output

SNo. Input Output
1
2
bba
scca

Yes
No

#include
using namespace std;
int main() {
int t;
cin>> t;
START:
while(t--){
string s;
cin>> s;
int ar={0};
for(int i=0;i<s.length();i++)ar[s.at(i)-'a'+1]++;
for(int i=0;i<s.length();i++){
if(ar[s.at(i)-'a'+1]!=s.at(i)-'a'+1){
cout<< "No"<<endl;
goto START;
}
}
cout<<"Yes"<< endl;
}
return 0;
}

Solution:
#include<iostream>
using namespace std;
int c;
int main(){
int t,len,flag=1;;
string s;
cin>>t;
while(t--){
cin>>s;
len=s.length();
for(int i=0;i<len;i++)
c[int(s[i])-int('a')]++;
for(int i=0;i<26;i++){
if(!(c[i]==0 || c[i]==i+1))
flag=0;
}
if(flag==1)
cout<<"Yes\n";
else
cout<<"No\n";
for(int i=0;i<26;i++)
c[i]=0;
flag=1;
}
return 0;
} Programming Geek
Source: programmaniaa blog.

*To get the more, view the [TCS] Super ASCII String Checker (CodeVita) Problem [Solved]. These are only for reference purpose.