First non-repeating character in a stream
Characters arrive one at a time. After each arrival, report the first
character seen so far that has appeared exactly once, or "#" if there is
none. Keep a count of each character in a dictionary, and a queue of
characters in arrival order. After each arrival, drop characters from the
front of the queue while their count is more than one; the front, if any,
is the answer.
Write first_unique_stream(text) that returns a string with one answer
character per arrival.
first_unique_stream("aabc") -> "a#bb"
first_unique_stream("abab") -> "aab#"
from collections import deque
def first_unique_stream(text):
...