FastPrepTrace Logs at a Two-Second Cadence
Problems/Trace Logs at a Two-Second Cadence

Trace Logs at a Two-Second Cadence

Klaviyo logoKlaviyo● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Klaviyo onsite interview. The report says to log a message every two seconds. Here, the function returns the output events as a list instead of waiting in real time. We chose the message, the first tick, the end time (included) and the output format. Our version is about 50% the same as the reported question. The report gives Klaviyo as the employer, even though its title mentions Coinbase.

For this exercise, start a virtual periodic logger at time 0 milliseconds and return its output events through durationMs.

  • The first event occurs at 2000 ms, then one event occurs every 2000 ms.
  • Include an event exactly at durationMs, but none after it. There is no time-zero event.
  • Every event carries the supplied message unchanged.

Return events in increasing time order as [timestamp, message] rows. Write each timestamp as a base-10 number of milliseconds with no leading zeros. Use virtual time and return the events immediately.

This function models output events rather than implementing a real browser timer.

Function

tracePeriodicLogs(durationMs: int, message: String) → String[][]

Examples

Example 1

durationMs = 5500message = "tick"return = [["2000","tick"],["4000","tick"]]

Events occur at 2000 and 4000 ms; the next event at 6000 ms is beyond the horizon.

Example 2

durationMs = 1999message = "ready"return = []

The first event is at 2000 ms, so this horizon contains no event.

Constraints

  • 0 <= durationMs <= 1000000.
  • 1 <= message.length <= 100.
  • Every message character is printable ASCII, with a code from 32 through 126.

More Klaviyo interview questions

  • Render Sidebar Labels as HTMLONSITE INTERVIEW · Seen Jul 2025
  • Validate Input Against Length BoundsONSITE INTERVIEW · Seen Jul 2025
  • Flatten JSON into Repeated Key-Value PairsONSITE INTERVIEW · Seen Oct 2023
  • Conditionally Insert or Update RecordsONSITE INTERVIEW · Seen Jul 2022
  • Progressive Parcel Tracking OperationsOA · Seen Aug 2026
  • Banking Transfers, Account Merges, and Historical BalancesOA · Seen Jul 2025
  • In-Memory Database with Permanent and Expiring ValuesOA · Seen Jul 2025
  • File Storage with User Quotas, Merging, Backups, and RestoreOA · Seen Jun 2025
  • Key-Value Locks with Waiting QueuesOA · Seen Sep 2024

Similar questions at other companies

  • Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Ring Buffer OperationsAmazon · ONSITE INTERVIEW
  • Count Distinct Underwriting PII ValuesAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Generate an Unbiased Bit from a Biased CoinGoogle · ONSITE INTERVIEWGoogle interview questions
  • Insert After a Linked-List NodeAMD · ONSITE INTERVIEWAMD interview questions
  • Document Edit EventsClickUp · ONSITE INTERVIEW
  • Virtual Card Transaction ValidatorCapital One · ONSITE INTERVIEWCapital One interview questions
  • Apply Overridden Integer TransformsOptimus Information · ONSITE INTERVIEWOptimus Information interview questions

Klaviyo interview experiences

  • Klaviyo SWE Intern Interview Questions: 15 Experiences
All Klaviyo interview questionsSee Klaviyo hiring insights
Saved
class Solution {
    public String[][] tracePeriodicLogs(int durationMs, String message) {
        // Write your code here
    }

}
Checking account…