




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The length of the longest subsequence does not exceed n/k. Do you know why?
Find the characters that could be included in the potential answer. A character occurring more than or equal to k times can be used in the answer up to (count of the character / k) times.
Try all possible candidates in reverse lexicographic order, and check the string for the subsequence condition.