You are given a string A consisting of lower case English letters. You have to find the first non-repeating character from each stream of characters.
For Example: If the given string is 'bbaca', then the operations are done as:
The first stream is “b” and the first non-repeating character is ‘b’ itself, so print ‘b’.
The next stream is “bb” and there are no non-repeating characters, so print nothing.
The next stream is “bba” and the first non-repeating character is ‘a’, so print ‘a’.
The next stream is “bbac” and the first non-repeating character is ‘a’, so print ‘a’.
The next stream is “bbaca” and the first non-repeating character is ‘c’, so print ‘c’.
Input Format:
The first line of input contains an integer ‘T’ representing the number of test cases. Then the test cases follow.
The only line of each test case contains a single string A consisting of only lowercase English letters.
Output Format:
For each test case, print a single character representing the first non-repeating character for each stream of characters.
The output for each test case is in a separate line.
Note:
You do not need to print anything; it has already been taken care of.
Constraints:
1 <= T <= 100
1 <= N <= 10000
Where ‘T’ is the number of test cases, and ‘N’ is the length of the string.
Time Limit: 1 sec.
1. Make hash_map which will map the character to there frequencies.
2. Traverse the string.
3. Increase the count of current character.
4. Traverse the string again and check whether the current characte...read more
A character is said to be non-repeating if its frequency in the string is unit. To find such characters, one needs to find the frequency of all characters in the s...read more
Make a count array to store the index of the character if it appears only once; else, it stores a negative value. So when it comes to finding the first non-repea...read more
We can use a Doubly Linked List to get the first non-repeating character from a stream efficiently. This can be done by storing all non-repeating characters in DLL. We will keep them...read more
Top Amdocs Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Amdocs Software Developer
Reviews
Interviews
Salaries
Users/Month