FastPrepFirst Non-Repeating Character in a Stream
Problems/First Non-Repeating Character in a Stream

First Non-Repeating Character in a Stream

Bloomberg LP logoBloomberg LP● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bloomberg new grad onsite interview, in a virtual onsite follow-up. The report directly gives the online first-non-repeating-character behavior and the full trace for google: g,g,g,null,l,l. We chose the batch interface, the lowercase limit, and an empty-string marker so it runs anywhere. Our version is about 93% the same as the reported question.

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.
  • stream contains 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 Interview Questions, Level Not Reported: 65 Questions

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)
See Bloomberg LP hiring insights
Saved
class Solution {
    public String[] firstNonRepeatingAfterEachInput(String stream) {
        // Write your code here.
    }

}
Checking account…