← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Senior

Senior
Apr 2026

Summary

Meta system design coding question, fourth level of a multi-part assessment. The problem built on previous levels and added grant periods with some tricky containment logic. Felt manageable but the edge cases on partial overlaps took longer than I expected.

Questions Asked (1)

Q1

Extend a work hours tracking system to support bonus salary periods: implement register_grant(start, end) to record double-pay windows, upgrade calc_salary so a session only gets doubled if it falls entirely within a registered grant period (partial overlap doesn't count), and implement get_grant_bonus(start, end) that returns the extra earnings tied to an exact previously registered grant.

System DesignAlgorithms & Data StructuresAPI & Integrations
Author's notes

The containment rule is where I lost time.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the data model and semantics first: define how sessions, grants, and salary calculations interact, especially the 'entirely within' condition and exact grant matching. Then outline an efficient data structure (e.g., interval tree or sorted list) to store grants and support fast containment queries, and walk through the implementation of each API with edge cases.

Pro tip: Explicitly discuss how you would handle overlapping grants and whether a session can be doubled more than once; this shows you think about real-world ambiguity and data integrity.

1. Clarify requirements and assumptions

Ask about session granularity, grant overlap rules, and whether get_grant_bonus should sum multiple sessions or return a single value. Confirm that 'exact previously registered grant' means matching start and end timestamps.

2. Design data structures

Propose storing grants in a balanced BST or interval tree keyed by start time, with end time as value, to enable O(log n) containment checks. For exact grant lookup, use a hash map keyed by (start, end).

3. Implement register_grant

Validate that start < end and handle duplicates or overlaps according to clarified rules. Insert into both the interval structure and the hash map.

4. Upgrade calc_salary

For each session, check if it is entirely contained within any grant (session.start >= grant.start and session.end <= grant.end). If so, double the pay for that session; otherwise, use normal rate.

5. Implement get_grant_bonus

Look up the exact grant by (start, end) in the hash map. Iterate over all sessions that fall entirely within that grant and sum the extra earnings (i.e., the additional amount beyond normal pay).

Key Points to Mention

  • Time complexity: O(log n) per containment check with interval tree, O(1) exact grant lookup with hash map.
  • Edge cases: sessions exactly matching grant boundaries, zero-length sessions, overlapping grants, and grants with no sessions.
  • Data integrity: ensure grants are immutable once registered or handle updates carefully.
  • Scalability: consider if sessions are many and grants are few, or vice versa, to choose the right data structure.
  • API design: discuss whether get_grant_bonus should return total bonus or per-session breakdown, and error handling for unknown grants.
  • Testing: unit tests for boundary conditions and integration tests for combined operations.

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