First Non-Repeating Character in a Stream
Updated
Problem statement
You receive the lowercase characters of a stream one at a time. After each new character, report the earliest character in the stream prefix whose frequency is exactly one.
If the current prefix has no non-repeating character, report the empty string for that step.
Given stream, return one result for every prefix in arrival order.
Function
firstNonRepeatingAfterEachInput(stream: String) → String[]Examples
Example 1
stream = "google"return = ["g","g","g","","l","l"]After the second g, o is still unique; after the second o, no unique character remains until l arrives.
Example 2
stream = "aabc"return = ["a","","b","b"]The second a removes the only candidate. Then b becomes and remains the earliest unique character.
Example 3
stream = "abc"return = ["a","a","a"]The first character never repeats, so it stays at the front for every prefix.
Constraints
1 <= stream.length <= 100000.streamcontains only lowercase English letters.
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- First Unique Character in a StreamAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Select First or Last K Stream WordsGoogle · PHONE SCREEN · ONSITE INTERVIEW
- Sliding-Window Rate LimiterStripe · PHONE SCREEN · ONSITE INTERVIEW
- Machine Message RouterOpenAI · PHONE SCREEN
- Earliest Unrepeated Letter in a StreamAdobe · PHONE SCREEN
- Classify Password StrengthHackerRank · OA · PHONE SCREEN · ONSITE INTERVIEW
- Highest Bid Campaign MatcherStackAdapt · ONSITE INTERVIEW
- Group AnagramsAmazon Web Services · ONSITE INTERVIEW
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEW
- File System Shell CommandsHarvey · ONSITE INTERVIEW
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)