title: Find first non-repeating character in a stream of characters
body: <p>This question is an extension of the following question:</p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/2285533/find-the-first-un-repeated-character-in-a-string">Find the first un-repeated character in a string</a></p>
  </blockquote>
  
  <p>My question is how to do this if instead of a string, we have a running stream of characters. Would the approach to use two arrays 'chars' and 'visited' as discussed in <a href="https://stackoverflow.com/a/2285561/913858">this solution</a> work fine for this problem too?</p>
  
  <p><strong>Edit</strong>: Sample input -  3333111124 
  Here 2 is the first non-repeating character, assume that the query findCharacter() is made at the time when the last character seen in stream is '4'.</p>
  
  <p>Note: The stream wont be stored  anywhere(in contrast to the above problem where the string is already available in memory), we will only have access to the last seen character of the stream.</p>