Any software role
Coding problem: Errors per Minute. Each entry of `lines` is one line of a service log in the form `<timestamp> <level> <message>`, for example `2025-03-14T09:26:53Z ERROR payment declined`. The timestamp is UTC in exactly the form `YYYY-MM-DDTHH:MM:SSZ` (a digit in every letter position), followed by one space and the level, a single word with no spaces. After the level there may be a space and a message, which can contain any text, or nothing at all.
TechnicalMid levelTests: Problem solving
Drill this questionCreate a free account to answer out loud with Ava and get feedback.
What the interviewer is looking for
- What a strong solution looks like: one pass; validate the prefix (a regex like ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z (\S+)( |$), or fixed-position checks), take the level token, compare level.upper() == "ERROR", count by line[:16]. O(total characters).
- Think aloud. Interviewers are judging how you reason, not only the final code.
- Be ready for: Report the worst minute, or every minute above a threshold. The log is 50 GB and keeps growing — how would you stream it, and what about late or out-of-order lines? How would you alert on a spike compared to the previous hour (rolling baseline)? What would you change if the format may evolve (structured logs)?
A structure to follow: Clarify, plan, code, test, analyse
- Step 1
Clarify
Restate the problem, ask about empty input, duplicates and size limits, and agree on one example.
- Step 2
Plan
Say the simple approach first and its cost, then the better one. Explain why before you type.
- Step 3
Code
Write small named steps and talk through each. A clear solution beats a clever one.
- Step 4
Test
Walk your own example through the code, then an edge case. Fix what you find calmly.
- Step 5
Analyse
State time and space cost in plain words and say what you would change for much larger input.
This is guidance on shape, not a script. Use your own real experience and facts; never invent details to fill a gap. See the STAR guide and answer frameworks.
Common slips
- Starting to code before agreeing what the answer must be.
- Going silent when stuck instead of saying what you are trying.
- Never running your own example through the code.
How to practise it
Solve it once in the editor without hints, then explain your solution aloud in under two minutes.
Related questions
- Coding problem: Pair With Target Sum. You are given a list of integers `nums` and an integer `target`. Return the positions of the two different entries that add up to `target`, as a list `[i, j]` with `i < j`.
- Coding problem: Balanced Brackets. Given a string `text`, decide whether its brackets are balanced. The bracket pairs are `()`, `[]` and `{}`; every other character is ignored.
- Coding problem: First Unrepeated Character. Given a string `text`, return the index of the first character that occurs exactly once in the whole string. Return `-1` if every character repeats.
- Coding problem: Palindrome After Cleanup. Decide whether `text` reads the same forwards and backwards once you drop every character that isn't a letter or a digit and ignore letter case.
- Coding problem: Totals by Category. Each record is an object `{"category": string, "amount": integer or null}` describing one sale, with the amount in cents. Return an object that maps each category to the sum of its amounts.