FastPrepParse Router Logs

Parse Router Logs

Intuit logoIntuit● MediumFULLTIMEOA

Problem statement

You are given a finite array of log lines. Keep only lines containing the exact, case-sensitive literal coderbyte heroku/router.

For each matching line, extract the fields request_id and fwd. Remove surrounding double quotes from a quoted field value while preserving its interior text. If the forwarded value is exactly MASKED, replace it with M.

Return one string per matching line in the format request_id [forwardedValue], with one space before the opening bracket. Preserve input order and repeated lines. An empty batch returns an empty array. The input is already captured log text; your function makes no network requests.

Function

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

Examples

Example 1

lines = ["2026-01-01 coderbyte heroku/router at=info request_id=\"abc-1\" fwd=\"1.2.3.4\" status=200","other application request_id=skip fwd=MASKED","coderbyte heroku/router request_id=r2 fwd=MASKED"]return = ["abc-1 [1.2.3.4]","r2 [M]"]

The first matching line gives request_id abc-1 and forwarded value1.2.3.4 after surrounding quotes are removed. The unrelated middle line is omitted. The last matching line maps the exact value MASKED to M.

Constraints

  • 0 <= lines.length <= 2000.
  • Each line has at most2000 characters.
  • The combined length of all lines is at most200000 characters.
  • Each line uses printable ASCII characters or tabs, without newline characters. In a matching line, whitespace-separated key=value fields use identifier keys; values are either nonempty unquoted tokens or double-quoted text with no interior quotes or escapes. request_id and fwd each occur exactly once with a nonempty value.

More Intuit problems

See Intuit hiring insights
Saved
public String[] parseRouterLogs(String[] lines) {
    // Write your solution here.
}
lines["2026-01-01 coderbyte heroku/router at=info request_id=\"abc-1\" fwd=\"1.2.3.4\" status=200","other application request_id=skip fwd=MASKED","coderbyte heroku/router request_id=r2 fwd=MASKED"]
expected["abc-1 [1.2.3.4]", "r2 [M]"]
Checking account…