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?
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 contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Python | Check order of character in string using OrderedDict( )
- LRU Cache in Python using OrderedDict
- OrderedDict in Python
- Python - Insertion at the beginning in OrderedDict
- Python List Comprehension | Segregate 0's and 1's in an array list
- Python | Remove Kth character from strings list
- Python program to find the character position of Kth word from a list of strings
- Move all zeroes to end of array using List Comprehension in Python
- Count set bits using Python List comprehension
- Python List Comprehension and Slicing
- List comprehension and ord() in Python to remove all characters other than alphabets
- Python List Comprehension | Sort even-placed elements in increasing and odd-placed in decreasing order
- Difference between List comprehension and Lambda in Python
- Python List Comprehension to find pair with given sum from two arrays
- Python List Comprehension | Three way partitioning of an array around a given range
- Python | List comprehension vs * operator
- Python - Map vs List comprehension
- How to handle a Python Exception in a List Comprehension?
- Python | Split string on Kth Occurrence of Character
- Python - Lowercase Kth Character in string