Problem Description
Given a string A denoting a stream of lowercase alphabets. You have to make new string B.
B is formed such that we have to find first non-repeating character each time a character is inserted to the stream and append it at the end to B. If no non-repeating character is found then append '#' at the end of B.
1 <= length of the string <= 100000
The only argument given is string A.
Return a string B after processing the stream of lowercase alphabets A.
Input 1:
A = "abadbc"
Input 2:
A = "abcabc"
Output 1:
"aabbdd"
Output 2:
"aaabc#"
Explanation 1:
"a" - first non repeating character 'a' "ab" - first non repeating character 'a' "aba" - first non repeating character 'b' "abad" - first non repeating character 'b' "abadb" - first non repeating character 'd' "abadbc" - first non repeating character 'd'
Explanation 2:
"a" - first non repeating character 'a' "ab" - first non repeating character 'a' "abc" - first non repeating character 'a' "abca" - first non repeating character 'b' "abcab" - first non repeating character 'c' "abcabc" - no non repeating character so '#'
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.