Track First Unique Character
Imagine building a real-time analytics dashboard that needs to identify the first unique character in a continuously incoming stream of data. This is crucial for various applications like anomaly detection, data processing, or even simple text analysis.
This problem challenges you to simulate this process, tracking the first character that has appeared exactly once, as new characters arrive in a stream.
Implement the function trackFirstUniqueChar that takes a string s representing a stream of characters. For each character processed in the stream (from left to right), you must:
s: A string consisting of lowercase English letters.output[i] should be the first unique character in s[0...i], or '#' if none exists.s is an empty string, return an empty array.s consists only of lowercase English letters ('a'-'z').s[0...i] is exactly one.Examples
Example 1
Input:
s = "abaccd"
Output:
["a", "a", "b", "b", "b", "b"]
Note:
Example 2
Input:
s = "aabbc"
Output:
["a", "#", "b", "#", "c"]
Note:
Constraints
1 <= s.length <= 10^5s consists only of lowercase English letters.Loading editor...