Cracking Meta's Software Engineer Interview: Navigating In-Memory K-V Storage Questions

meta | Software Engineer | Interview Experience

Interview Date: Not specified
Result: Not specified
Difficulty: Not specified

Interview Process

The interview consisted of a technical assessment focused on a key-value storage problem. The candidate was given a set of requirements and had to implement methods for setting and getting values, as well as managing time-to-live (TTL) for records. The candidate completed the coding task within 60 minutes, ensuring all tests passed successfully.

Technical Questions

  • Implement methods for:
    • set(timestamp, key, field, value)
    • get(timestamp, key, field)
    • compareAndUpdate(timestamp, key, field, expectedValue, newValue)
    • compareAndDelete(timestamp, key, field)
    • scan(timestamp, key, field)
    • scanByPrefix(timestamp, key, field, prefix)
    • setWithTTL(timestamp, key, field, value, ttl)
    • compareAndUpdateWithTTL(timestamp, key, field, expectedValue, newValue, TTL)
    • getValueAt(timestamp, key, field, atTimestamp)

Tips & Insights

  • Use a Map<String, Map<String, Integer>> for basic implementation.
  • For prefix scanning, utilize TreeMap to efficiently manage submaps.
  • Implement a Record class to handle values with and without TTL, including methods to check expiration.
  • Maintain a history of changes in a separate map to facilitate querying past states efficiently.