Just another episode in Johnny Test
All submissions for this problem are available.
Before you start solving this question i am assuming that you are already aware of the fact that there are several arch nemesis of Johnny and his genius identical twin sisters, Susan And Mary. Some of these enemies include Eugene "Bling-Bling Boy", Dark Vegan (a space warlord from planet Vegandon) ,Sissy Blakely, Bumper and many others. This information is necessary because a war is coming and knowing about your enemies always help.
As already mentioned a war will wage between Johnny and his enemies in which if Johnny gets defeated then it would mean the end of world so he needs help from you all. But in order to help you must be qualified to do so and for checking that Johnny along with his sisters has prepared a qualification test.
The problem statement of test states that you will be given a string 'str' in which you need to print the Lexicographically smallest increasing sequence of length 'k'.For those who do not understand meaning of increasing sequence, it basically means: str[i]<=str[i+1]<=str[i+2]<=str[i+3]<=......<=str[k], where 1<=i
The first line consist of single integer 'T' denoting the number of test cases.Each test case consist of two lines, first line consists of two integer 'N' and 'k' denoting length of string and length of expected increasing sequence respectively.The second line consist of a string of length 'N' characters.
For each test case if there exist an increasing sequence of string of length 'k' then print 'Yes' in the first line and in second line print the resultant string. Otherwise print out 'No'.
- 1 ≤ T ≤ 10^5
- 1 ≤ N,k ≤ 10^5
String consists of only lower case alphabets.
Input: 2 5 2 zyxab 5 5 adhoc Output: Yes ab No
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5|
Fetching successful submissions
If you are still having problems, see a sample solution here.