← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Meta SWE interview with a log sorting problem. Pretty straightforward premise but the follow-up about inconsistent formats is where things got interesting.

Questions Asked (1)

Q1

Given a list of logs with timestamps, sort them according to some business logic. How would you handle inconsistent log formats to make sorting work?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The base sorting part was fine, I talked through a custom comparator and parsing the timestamp out of each string.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the business logic for sorting and the expected log formats, then propose a normalization pipeline that parses each log into a canonical structure before sorting. Discuss trade-offs between strict parsing, lenient parsing, and fallback strategies, and how to handle unparseable logs.

Pro tip: Mention that you would log and monitor parsing failures to detect format drift over time, and consider a schema registry or versioned parsers for long-term maintainability.

1. Clarify requirements and constraints

Ask about the business logic for sorting, the expected log formats, and the scale of data. Determine if sorting is by timestamp, severity, or a custom key, and whether logs are streaming or batch.

2. Design a normalization strategy

Propose parsing each log into a canonical structure (e.g., a LogEntry object) with a unified timestamp format. Use a parser that tries multiple formats and falls back to a default or flags unparseable logs.

3. Implement sorting with a custom comparator

Sort the normalized entries using the business logic. For inconsistent formats, ensure the comparator handles missing or invalid fields gracefully, perhaps by placing them at the end or using a secondary sort key.

4. Handle edge cases and errors

Decide how to treat logs that cannot be parsed: skip, log an error, or assign a default timestamp. Discuss monitoring and alerting for format inconsistencies.

5. Discuss trade-offs and scalability

Compare approaches: pre-processing vs. on-the-fly parsing, strict vs. lenient parsing, and in-memory vs. external sorting. Consider performance implications for large datasets.

Key Points to Mention

  • Timestamp normalization (e.g., ISO 8601, epoch) and timezone handling
  • Use of regular expressions or parser combinators for flexible log parsing
  • Custom comparator design that respects business logic and handles nulls
  • Error handling and logging for unparseable logs
  • Trade-offs between parsing at ingestion vs. query time
  • Scalability considerations: external sorting, streaming, or distributed sorting

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.