![]() |
VOOZH | about |
Given a string 's' and an integer 'k', the task is to find the K’th non-repeating character in the string. A non-repeating character is one that appears exactly once.
Example:
Input: "geeksforgeeks"
k=3Output: "r"
Explanation: In "geeksforgeeks", the characters that appear only once are f, o, and r. The third non-repeating character is "r".
Counter quickly counts how many times each character appears, making it easy to pick out non-repeating ones.
r
Explanation:
OrderedDict keeps track of the order characters appear while counting them.
r
Explanation:
This method uses a normal dictionary to count characters, then collects the non-repeating ones.
r
Explanation:
This approach counts frequencies and filters non-repeating characters using list comprehension.
r
Explanation: [ch for ch in s if freq[ch] == 1]: Collects characters appearing only once.