Answer to Question #53861 in C++ for Kamal

Question #53861
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').
1
Expert's answer
2015-08-04T02:29:28-0400
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;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS