Problem · Queue

Log Buffer Analyzer

MediumGoldman SachsOA

You receive n logs in increasing timestamp order. Log j has:

  • logTimestamp[j] (milliseconds)
  • logTag[j] (a string)

The system keeps logs in a circular buffer of size bufferCapacity. When a new log arrives:

  • Add the new log to the buffer.

Transmit every log currently in the buffer that:

  • has the same tag as the new log, and
  • has timestamp t such that newTimestamp - t <= transmissionWindow

If adding the new log makes the buffer exceed bufferCapacity, remove the oldest log.

Return the total number of transmitted logs over all arrivals, counting logs each time they are transmitted.

The function getTotalTransmittedLogs takes the following parameters:

  • int logTimestamp[n]: the recording times of logs in milliseconds
  • string logTag[n]: the tags of logs
  • int bufferCapacity: the capacity of the circular buffer
  • int transmissionWindow: the time range (in milliseconds) within which logs sharing the same tag as the arriving log are transmitted

The function should return the number of logs transmitted during the process as an integer.

Examples
01 · Example 1
logTimestamp = [1000, 2000, 3000, 4000]
logTag = ["error", "warning", "error", "warning"]
bufferCapacity = 3
transmissionWindow = 2000
return = 6

Processing the log arrivals:

  1. At timestamp 1000, the buffer contains the new error log, so 1 log is transmitted.
  2. At timestamp 2000, the buffer contains the new warning log, so 1 log is transmitted.
  3. At timestamp 3000, both error logs at 1000 and 3000 are within the window, so 2 logs are transmitted.
  4. At timestamp 4000, both warning logs at 2000 and 4000 are within the window, so 2 logs are transmitted.

The total number of transmitted logs is 1 + 1 + 2 + 2 = 6.

Source correction (June 28, 2026): I found a newer source image that showed this example and function name differently, so I updated this version to match it. If you have the full prompt or see something off, please tell us and we'll fix it. If a clearer source shows up later, I'll update this again. 🐿️

Source note (June 28, 2026): The original post did not include the output for this example. FastPrep worked it out from the problem statement and the given input. If you have the original output or notice something wrong, please let us know and we'll fix it. If we find the original source later, we'll come back and update this too. 🦦

More Goldman Sachs problems
drafts saved locally
public int getTotalTransmittedLogs(int[] logTimestamp, String[] logTag, int bufferCapacity, int transmissionWindow) {
  // write your code here
}
logTimestamp[1000, 2000, 3000, 4000]
logTag["error", "warning", "error", "warning"]
bufferCapacity3
transmissionWindow2000
expected6
checking account