Company: Hackerearth_1nov
Difficulty: medium
K Frequency Problem Description For a string S of lowercase English letters, count how often each letter occurs. Collect the distinct counts and sort them from largest to smallest. The K -th entry of that list is the target count. Print the letter whose count equals the target; if several letters share it, print the alphabetically smallest of them. If the list of distinct counts is shorter than K , print -1 . Function Description Complete the function solve in the editor below. solve has the following parameters: s : the string. k : which distinct count to pick, counting from the largest. Returns: the answer for one test case, either a single character or -1 . Input Format The first line contains the integer T , the number of test cases. For each test case, the first line contains the string S and the second line contains the integer K . Output Format For each test case print the answer on its own line. Constraints 1 <= T <= 10 1 <= |S| <= 18000 (inferred -- lowered from 10