Interview conceptCoding & Algorithms

CSV Parsing, Validation, And Joins

Asked of: Software Engineer

Last updated

What's being tested

These problems test CSV parsing, record validation, and join/aggregation algorithms over semi-structured text data. You must preserve input order where required, define duplicate-key and malformed-row behavior, and choose between straightforward scanning, sorting, or hash-based indexing. Strong solutions separate normalization, validation, and output formatting so edge cases are explicit and testable.

Patterns & templates

  • Use Python's csv.reader or csv.DictReader; handle quoted commas, escaped quotes, headers, blank lines, and malformed records deliberately.

  • Normalize comparison fields with strip(), casefold(), whitespace tokenization, and stop-word removal before forbidden-word or overlap checks.

  • Build a hash index key -> list[record] for joins; preserve every left row and emit all matching right rows, giving O(n + m + output) time.

  • For sorted joins, sort both inputs by key and advance two pointers; complexity is O(n log n + m log m) with lower auxiliary indexing overhead.

  • Validate each row independently, collecting deterministic error codes; distinguish missing, empty, overlong, forbidden, and structurally malformed fields.

  • Aggregate changed files through file -> owners and owner -> changed files maps; deduplicate reviewers while retaining a specified stable ordering.

Common pitfalls

Pitfall: Treating CSV as line.split(",") breaks quoted commas and embedded quotes; use a standards-aware parser.

Pitfall: Implementing a dictionary join as one-to-one silently drops duplicate matches; store lists and define the Cartesian expansion explicitly.

Pitfall: Calling lower() without trimming, tokenizing, or removing ignored words produces inconsistent overlap and forbidden-word results.

Practice these

The practice cards below cover the canonical variants — solve all of them and time yourself.

Practice questions

Related concepts