FastPrepHost Log Parser
Problems/Host Log Parser

Host Log Parser

Verkada logoVerkada● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report provides timestamp alternatives, key grammar, quoted-value behavior, blank-line handling, and a streaming requirement. The returned row format exposes the same single-pass parsing capability to a finite runner.

Parse host log lines into structured fields while processing each line from left to right.

A non-blank line begins with either a no-space ISO timestamp or a timestamp in the form YYYY-MM-DD HH:mm:ss.SSS. The remainder contains whitespace-delimited key=value fields. Keys contain only letters, digits, underscore, dot, or hyphen. An unquoted value ends at whitespace. A quoted value may contain spaces and equal signs, supports \" as an escaped quote, and may be empty.

For every non-blank line, return one row whose first element is the complete timestamp and whose remaining elements are normalized key=value strings in source order. Remove surrounding quotes and replace each escaped quote with a literal quote. Skip blank lines.

Function

parseHostLogs(lines: String[]) → String[][]

Examples

Example 1

lines = ["2026-09-29T10:20:30Z host=api-1 status=ok","2026-09-29 10:20:31.123 msg=\"retry later\" code=503"]return = [["2026-09-29T10:20:30Z","host=api-1","status=ok"],["2026-09-29 10:20:31.123","msg=retry later","code=503"]]

The second timestamp spans two tokens, while the quoted message remains one value.

Example 2

lines = ["2026-01-01T00:00:00Z note=\"a=b and \\\"quoted\\\"\" empty=\"\""]return = [["2026-01-01T00:00:00Z","note=a=b and \"quoted\"","empty="]]

Equal signs and escaped quotes inside a quoted value are preserved.

Example 3

lines = ["","   ","2026-05-06 07:08:09.010 a=1\tb=two"]return = [["2026-05-06 07:08:09.010","a=1","b=two"]]

Blank lines are skipped and tabs delimit fields.

Constraints

  • 0 <= lines.length <= 100000.
  • Each line has at most 10000 characters.
  • Every non-blank line follows the stated grammar.
  • Fields are separated by one or more spaces or tabs.

More Verkada problems

  • Find the Unique User with Access to Every CameraPHONE SCREEN · Seen Sep 2026
  • Valid SudokuPHONE SCREEN · Seen Sep 2026
  • Common Camera Motion IntervalsPHONE SCREEN · Seen Sep 2026
All Verkada interview questionsSee Verkada hiring insights
Saved
class Solution {
    public String[][] parseHostLogs(String[] lines) {
        // Write your solution here.
    }
}
Checking account…