Array ( [0] => [1] => questions [2] => Codevita-Previous-Questions [3] => 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.
First line contains number of test cases T, followed by T lines, each containing a string "S".
Constraints:
1<=T<=100
1<=|S|<=400, S will contains only lower case alphabets ('a'-'z').
For each test case print "Yes" if the String "S" is super ascii, else print "No"
2 bba scca
Yes No
2 bbaa ddddccca
No Yes
2 bbaa scca
No No
Login to see Discussion
Maintaining a count array, which stores the count of the characters at their (ascii-1) positions. At last iterate through the count array, by maintaining a flag value, if the count at that position is greater than the ascii, set the flag to '0' and break the loop.
Note :
Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.
Login to see Solution