K’th Non-repeating Character in Python using List Comprehension and OrderedDict
Given a string and a number k, find the k-th non-repeating character in the string. Consider a large input string with lacs of characters and a small character set. How to find the character by only doing only one traversal of input string? Examples:
Input : str = geeksforgeeks, k = 3 Output : r First non-repeating character is f, second is o and third is r. Input : str = geeksforgeeks, k = 2 Output : o Input : str = geeksforgeeks, k = 4 Output : Less than k non-repeating characters in input.
This article is contributed by Shashank Mishra (Gullu). If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.