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').
Answer
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main()
{
int t;
cout<<"Enter the number of cases: ";
cin>>t;
cin.ignore(7777,'\n');
for (int i=0;i<t;i++)
{
string str;
bool b=1;
getline(cin,str);
map<char, int>s;
vector<char>vc;
for (auto c:str)
{
s[c]++;
if (s[c]==1)
vc.push_back(c);
}
for (auto c:vc)
{
if (s[c]!=int(c)-96)
b=0;
}
if (b)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}