FastPrepStream Latest Log Versions
Problems/Stream Latest Log Versions

Stream Latest Log Versions

Google logoGoogle● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes keeping the newest timestamp for each message and lazily dropping old versions from the heap. It does not give a finite operation format, the order for equal times, what to do when empty, or what happens after a log is emitted. Our version is about 85% the same as the reported question.

Process a finite sequence of log-stream operations from left to right. Each log is a pair containing an integer timestamp and a message. At most one version of each message is pending at a time.

  • For an add operation, if the message is not pending, make the supplied log its pending version. If the message is already pending, replace its pending version only when the supplied timestamp is greater. An equal or smaller timestamp leaves the current version unchanged.
  • For a get operation, remove and return the pending version with the smallest timestamp. If multiple pending versions have the same timestamp, return the one whose message is lexicographically smaller. If no version is pending, return EMPTY.

After a version is returned, that message is no longer pending. A later add for the same message starts a new pending lifecycle, regardless of the timestamp that was returned earlier. Only operations already processed are visible, and later operations never revise a returned result.

Return one string for each get, in operation order. Encode a returned log as timestamp|message. The timestamp and message entries at a get position are placeholders and are ignored.

Function

processLatestLogs(operations: String[], timestamps: int[], messages: String[]) → String[]

Examples

Example 1

operations = ["add","add","add","get","get","add","get"]timestamps = [5,8,3,0,0,2,0]messages = ["build","build","deploy","","","build",""]return = ["3|deploy","8|build","2|build"]

The timestamp 8 version replaces build at timestamp 5. The first two results are therefore 3|deploy and 8|build. Once build is returned, adding it at timestamp 2 starts a new lifecycle.

Example 2

operations = ["add","add","add","add","get","get","get"]timestamps = [4,4,4,2,0,0,0]messages = ["alpha","alpha","beta","alpha","","",""]return = ["4|alpha","4|beta","EMPTY"]

The equal and smaller updates for alpha are ignored. Its timestamp ties with beta, so message order returns alpha first. The final get is empty.

Constraints

  • 1 <= operations.length <= 10^5.
  • operations.length == timestamps.length == messages.length.
  • Every operation is either add or get.
  • At an add position, 0 <= timestamps[i] <= 10^9.
  • At an add position, messages[i] contains between 1 and 20 lowercase English letters.
  • At a get position, timestamps[i] and messages[i] are ignored.

More Google Onsite Interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Design Authentication ManagerOracle · ONSITE INTERVIEWOracle interview questions
  • Thread-Safe Task Storage and Worker DispatchNuro · ONSITE INTERVIEWNuro interview questions
  • Notification Deduplication WindowGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Helpdesk Ticket ProcessingThe Walt Disney Company · ONSITE INTERVIEWThe Walt Disney Company interview questions
  • Execute Tasks by PrioritySnowflake · ONSITE INTERVIEWSnowflake interview questions
  • Worker Assignment — Skills and Account AffinityStripe · ONSITE INTERVIEWStripe interview questions
  • 15-Minute Chat Session TrackerOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • LRU Cache with TTLAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Scheduled Payments with Account AliasesCoinbase · ONSITE INTERVIEWCoinbase interview questions
  • Keyed Bounded Executor ScheduleMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public String[] processLatestLogs(String[] operations, int[] timestamps, String[] messages) {
        // Write your code here.
    }
}
Checking account…