Marks :30
: 10 | : 0
Bob gave Alex a string $$$s$$$ consisting of lowercase English letters of length $$$n.$$$ He then asked Alex to construct a new string $$$s1$$$ using the characters of $$$s$$$ such that no two characters appear more than $$$k$$$ times consecutively. It is not mandatory to use all characters from $$$s.$$$
Help Alex find the lexicographically largest possible string $$$s1.$$$
The first line contains two space-separated integers $$$n$$$ and $$$k$$$. The second line contains a string $$$s$$$ of length $$$n$$$.$$$(1 \le n \le 10^5).$$$$$$( 1\le k \le n.)$$$
Output the lexicographically largest string.
7 3 xxxxzza
zzxxxax
19 3 zzzzzzxxxzzaabbazza
zzzxzzzxzzzxzbbaaa
9 2 cledqiwly
ywqlliedc
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.