Marks :50
: 2 | : 1
There is a game called Jisho in Japan. In that, players are given an integer $$$alpha$$$ and a string $$$beta$$$ to play with. The players have to choose some positions (indexes) from the string such that at least 1 position from the chosen set is present in any continuous substring of length $$$alpha$$$.
The players then have to form the smallest lexicographic string with the help of the letters corresponding to those indices (they can rearrange the letters to form the smallest lexicographic string).
Adi wants to win the game, therefore, he comes to you for help. Help Adi by returning the smallest lexicographic string possible with these conditions.
You can learn more about lexicographic strings here.
The first line of input consists of the string $$$beta$$$ $$$(1 \leq |beta| \leq 10^5)$$$. The string consists of only lowercase Latin letters. The second line of input consists of a single integer $$$alpha$$$ $$$(1 \leq alpha \leq |beta|)$$$.
The output should consist of a single string $$$-$$$ the smallest possible lexicographic string.
aacaa 4
a
abcab 2
aab
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.