Lexicographical Smallest String

There is a string s of length n containing lowercase letters and an integer k. Among the letters those appear exactly k times in string s, pick the lexicographically maximum one. Now delete any (k-1) occurrences of this letter from the string in a way so that the resultant string is lexicographically smallest.


This is a companion discussion topic for the original entry at https://toph.co/p/lexicographical-smallest-string

I get error in 11 th case.May one can know the test case after submission like CF?
my code: https://ideone.com/TZBlo7