DECSTR :-what does the prob mean??

wht does the question says(feeling quite stupid…:))???unable to understand it??

u need to print a string such that in it there are ‘k’ positions where the char on any of those positions the are alphabetically larger than the char on the next position…!!!

for example:- s=“abcdefghijklmnopqrstuvwxyz”

in this there is no such position at which the char on the next position is alphabetically smaller!!!

another example:- s=“dbca”

in this at pos 1 that is at char=‘d’ the next char is ‘b’ which is alphabetically smaller…and at pos 2 that is char=‘b’ the next char is ‘c’ which is not alphabetically smaller…and at pos 3 that is char=‘c’ the next char is ‘a’ which is alphabetically smaller…therefore in the string “dbca” there are 2 such positions where the above given condition holds…therefore this is a correct ans for k=2…but will not be AC as the string can be made smaller in length and also lexographically…!!!

Hope this will help…:slight_smile:

1 Like