Instacart·Software Engineer·Technical Phone Screen
- You have a multi-gigabyte credentials file on disk, one record per line formatted as user_id, salt, and a hex password hash. The file is unsorted and can't be fully loaded into memory. Implement a validate(user_id, password) function. First, build a streaming solution that scans lines sequentially with constant memory and stops as soon as the user is found. Then propose an offline indexing strategy that maps user IDs to byte offsets so future lookups are sublinear. Walk through trade-offs, encoding/error handling, memory-mapped vs buffered I/O, and time and space complexity for both approaches.
“This one had more surface area than I expected going in.”