PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Instacart

Optimize file reads for password validation

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in on-disk file I/O, streaming algorithms, offline indexing for sublinear lookups, and system-level performance considerations for validating credentials in large files.

  • Medium
  • Instacart
  • Coding & Algorithms
  • Software Engineer

Optimize file reads for password validation

Company: Instacart

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: HR Screen

Given a multi-gigabyte credentials file on disk with one record per line in the format user_id,salt,password_hash (hex), implement validate(user_id, password) -> bool. The file is unsorted and cannot be fully loaded into memory. Optimize space by only reading the content needed. Propose and implement: (a) a streaming approach that scans lines with constant memory and stops early when the user is found; (b) an optional offline indexing strategy (e.g., build a user_id -> byte offset index) to enable sublinear lookups on subsequent runs. Discuss trade-offs, file encoding/error handling, memory-mapped I/O vs buffered reads, and time/space complexity.

Quick Answer: This question evaluates proficiency in on-disk file I/O, streaming algorithms, offline indexing for sublinear lookups, and system-level performance considerations for validating credentials in large files.

Related Interview Questions

  • Find Largest Adjacent Stock Price Change - Instacart (medium)
  • Implement an In-Memory File Storage System - Instacart (medium)
  • Evaluate an arithmetic expression - Instacart (medium)
  • Decode an encoded string - Instacart (medium)
  • Implement worker time and payroll tracker - Instacart (hard)
Instacart logo
Instacart
Jul 31, 2025, 12:00 AM
Software Engineer
HR Screen
Coding & Algorithms
4
0

Given a multi-gigabyte credentials file on disk with one record per line in the format user_id,salt,password_hash (hex), implement validate(user_id, password) -> bool. The file is unsorted and cannot be fully loaded into memory. Optimize space by only reading the content needed. Propose and implement: (a) a streaming approach that scans lines with constant memory and stops early when the user is found; (b) an optional offline indexing strategy (e.g., build a user_id -> byte offset index) to enable sublinear lookups on subsequent runs. Discuss trade-offs, file encoding/error handling, memory-mapped I/O vs buffered reads, and time/space complexity.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Instacart•More Software Engineer•Instacart Software Engineer•Instacart Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.