Reported September 2024
Google

Optimize Log Files

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google's September OA included a log file optimization problem, and it's the kind of question that feels straightforward until you realize the real constraint. You're looking at a classic string or parsing task, but the trick is figuring out what "optimize" actually means in Google's context. It could be sorting by timestamp, deduplicating, filtering by severity, or restructuring for fast lookup. The pattern matters. StealthCoder is your safety net if you freeze on the exact optimization criteria during the live assessment.

Pattern and pitfall

Log optimization at Google typically hinges on either sorting (by timestamp, severity, or source), deduplication (removing redundant entries), or fast retrieval (hash-table or indexing). The common pitfall is spending time optimizing the wrong dimension. Read the problem statement carefully for what "optimize" means: is it speed, memory, or output format. If it's sorting, you're likely looking at a comparator-based sort or radix sort for timestamps. If it's deduplication or lookup, hash-tables or sets are your path. The real win is catching the constraint early: file size, query patterns, or memory limits. StealthCoder can surface the exact requirement instantly if you're uncertain, letting you code the right solution instead of guessing.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Optimize Log Files cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Optimize Log Files FAQ

What does 'optimize' mean in this Google problem?+

It depends on the full problem statement, but Google's log optimization questions usually ask you to either sort by a field (timestamp, severity, host), deduplicate entries, or structure logs for fast queries. The input will specify which. Read it twice before coding.

Is this a sorting problem or a hash-table problem?+

Both are possible. If the goal is to reorder logs by a key, sorting. If it's dedup or lookup by ID, hash-table. The problem text tells you which. Don't assume; it changes the approach entirely.

How do I parse log entries quickly?+

Split each line by a delimiter (space, tab, pipe). Store fields in a tuple or object. Use regex only if the format is irregular. Simple string split is faster and less error-prone. Google's inputs are usually well-formed.

What's the time complexity expected?+

If sorting, O(n log n). If hash-based, O(n). The problem likely won't ask for better than O(n log n) on a large file. Don't overthink micro-optimizations unless the problem explicitly limits file size to millions of lines.

Can I solve this in 15-20 minutes?+

Yes. Parse, sort or deduplicate, output. The logic is simple. The challenge is catching the exact optimization rule from the problem text. Read carefully. Implement fast. Test on the sample.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it