FastPrepFirst Unique Event in a Stream
Problems/First Unique Event in a Stream

First Unique Event in a Stream

Google logoGoogle● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: This was a PhD intern interview. This problem is rebuilt. The report only keeps that it used streaming with a deque and a hash map. The task of finding the first unique event at each prefix is our own rebuild. Our version is about 30% the same as the reported question.

You receive a stream of string events in order. After processing each event, report the earliest event value that has appeared exactly once in the entire prefix processed so far.

If the current prefix has no event value with frequency one, report the empty string for that position. Return one answer for every processed event.

Function

firstUniqueAfterEachEvent(events: String[]) → String[]

Examples

Example 1

events = ["a","b","a","c"]return = ["a","a","b","b"]

After the third event, a is repeated, so b becomes the earliest value seen exactly once. Adding c does not change that earliest unique value.

Example 2

events = ["x","x","y","y"]return = ["x","","y",""]

The second and fourth prefixes contain no value with frequency one, so their answers are empty strings.

Example 3

events = []return = []

An empty stream produces no prefix answers.

Constraints

  • 0 <= events.length <= 200000
  • 1 <= events[i].length <= 30
  • Each event contains lowercase English letters.

More Google Phone Screen questions

  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
  • Minimum Total Layover WaitPHONE SCREEN · Seen Nov 2026
  • Reach a Destination Through Scheduled FlightsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • String Interpolation with a Missing-Value ModeMongoDB · PHONE SCREENMongoDB interview questions
  • Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • First Unique Character in a StreamAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Fixed-Order Task Run Time With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Character Counts with Retried Remote WorkersCoalition · PHONE SCREEN

Interview reports that mention this question

  • Google SWE Intern Onsite Questions: 16 Experiences (Part 2 of 3)

Google interview experiences

  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
  • Google AI Coding Interview and AI OA: 2 Experiences
  • Google SWE Intern Interview Results Timeline: 13 Experiences
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] firstUniqueAfterEachEvent(String[] events) {
        // Write your code here.
    }
}
Checking account…