#K44017. Find the K-th Non-Repeating Character

    ID: 27438 Type: Default 1000ms 256MiB

Find the K-th Non-Repeating Character

Find the K-th Non-Repeating Character

You are given a string S and an integer K. Your task is to find the K-th non-repeating character in the string. A non-repeating character is one that appears exactly once in S. If there are fewer than K non-repeating characters, output an empty string.

Note: The counting is 1-indexed, that is, the first non-repeating character is when K = 1.

Example:
For S = "geeksforgeeks" and K = 3, the non-repeating characters in order are ["f", "o", "r"]. Thus the answer is "r".

All formulas are formatted in LaTeX. For instance, if you need to refer to the condition for a unique character, you can write it as: $$frequency(x)=1$$ for each character \( x \) in S.

inputFormat

The input is read from standard input (stdin). The first line contains a non-empty string S. The second line contains an integer K. It is guaranteed that S contains only ASCII characters.

outputFormat

Output the K-th non-repeating character of string S to standard output (stdout). If there are fewer than K non-repeating characters, print an empty line.## sample

geeksforgeeks
3
r