This visualization demonstrates how to find the first non-repeating character in a stream of characters. As each character arrives in the stream, we keep track of all characters seen so far and identify the first non-repeating character at each step.
Stream: "abac"
Character | Count |
---|---|
a | 1 |
Character | Count |
---|---|
a | 1 |
b | 1 |
Since both 'a' and 'b' appear once, the first one ('a') remains the first non-repeating character.
Character | Count |
---|---|
a | 2 |
b | 1 |
'a' now appears twice, so it's no longer non-repeating. 'b' becomes the first non-repeating character.
Character | Count |
---|---|
a | 2 |
b | 1 |
c | 1 |
Now both 'b' and 'c' appear once, but 'b' came first, so it remains the first non-repeating character.
Character | Count | Status |
---|---|---|
a | 2 | Repeating |
b | 1 | Non-repeating |
c | 1 | Non-repeating |
After processing the entire stream "abac", the first non-repeating character is 'b'.