PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Nuro

Parse logs and count error codes

Last updated: Mar 29, 2026

Quick Overview

This question evaluates parsing and sanitizing structured text, extracting specific fields, and performing frequency aggregation of identifiers such as error codes, demonstrating string-processing and robustness skills.

  • easy
  • Nuro
  • Coding & Algorithms
  • Software Engineer

Parse logs and count error codes

Company: Nuro

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

You are given application log lines. Each line is expected to follow this format: ``` [LEVEL] timestamp, eventName, errorCode, text ``` - `LEVEL` is a single character such as `I`, `W`, `E` inside square brackets (e.g., `[I]`). - Fields after the level are separated by commas. - `text` may contain arbitrary characters (assume it does **not** contain a newline). ### Task Write a Python function that parses a list of log lines and returns the count of each `errorCode`. ### Input - A list of strings `lines`, where each string is one log line. ### Output - A dictionary/map from `errorCode` (string) to its occurrence count (integer). ### Requirements / Edge cases - Trim extra whitespace around comma-separated fields. - Ignore lines that do not match the expected format (do not crash). - Treat `errorCode` as a string (e.g., `"404"`, `"E123"`). ### Example Input: ``` [I] 2026-01-01T00:00:00Z, Login, E123, user not found [W] 2026-01-01T00:00:01Z, Login, E123, retry [E] 2026-01-01T00:00:02Z, Payment, P007, declined ``` Output: ``` { "E123": 2, "P007": 1 } ```

Quick Answer: This question evaluates parsing and sanitizing structured text, extracting specific fields, and performing frequency aggregation of identifiers such as error codes, demonstrating string-processing and robustness skills.

Related Interview Questions

  • Group points by distance threshold - Nuro (medium)
  • Find Maximum Path Sum in N-ary Tree - Nuro (hard)
  • Find gaps between intervals - Nuro (medium)
  • Implement BFS and a Job Scheduler - Nuro (hard)
Nuro logo
Nuro
Feb 12, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0
Loading...

You are given application log lines. Each line is expected to follow this format:

[LEVEL] timestamp, eventName, errorCode, text
  • LEVEL is a single character such as I , W , E inside square brackets (e.g., [I] ).
  • Fields after the level are separated by commas.
  • text may contain arbitrary characters (assume it does not contain a newline).

Task

Write a Python function that parses a list of log lines and returns the count of each errorCode.

Input

  • A list of strings lines , where each string is one log line.

Output

  • A dictionary/map from errorCode (string) to its occurrence count (integer).

Requirements / Edge cases

  • Trim extra whitespace around comma-separated fields.
  • Ignore lines that do not match the expected format (do not crash).
  • Treat errorCode as a string (e.g., "404" , "E123" ).

Example

Input:

[I] 2026-01-01T00:00:00Z, Login, E123, user not found
[W] 2026-01-01T00:00:01Z, Login, E123, retry
[E] 2026-01-01T00:00:02Z, Payment, P007, declined

Output:

{ "E123": 2, "P007": 1 }

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Nuro•More Software Engineer•Nuro Software Engineer•Nuro Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.