Skip to interview prep
Apexed

61. You must find the most frequent error codes in a log file larger than memory. How would you approach it?

MediumData structures & algorithms

Technical

Type or dictate your answer. Your draft is saved on this device.

Show model answer

Clarify whether exact counts are required and how many distinct codes may exist. Stream the file and update a frequency map if the distinct set fits in memory; the file size alone does not make that map too large.

If the distinct set is unbounded, partition or externally sort the data, or agree on an approximate streaming method with explicit error bounds. State input-reading and storage costs, handle malformed lines, and compare results against a small trusted fixture.

What interviewers listen for

  • Separate input size from distinct count
  • Bounded-memory strategy
  • Exactness and cost tradeoffs
You must find the most frequent error codes in a log file larger than memory. How would you approach it — Software engineering interview question — Apexed