Implement prefix and suffix file search

Quick Overview

This question evaluates the ability to design and implement efficient string-indexing data structures and APIs for prefix-and-suffix matching, demonstrating competency with tries, suffix-related structures, inverted indexes, and time/space complexity trade-offs.

Implement prefix and suffix file search

Company: Instacart

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

Implement data structures and APIs to store file names and support efficient queries that match both a given prefix and suffix. Provide methods add(name: string) and find(prefix: string, suffix: string) -> list of names (or IDs) that match both constraints, returning results in lexicographic order. Support up to 100,000 insertions and many queries with near-real-time updates; analyze time and space complexity and discuss alternatives (e.g., two tries, suffix automaton, inverted indexes).

Quick Answer: This question evaluates the ability to design and implement efficient string-indexing data structures and APIs for prefix-and-suffix matching, demonstrating competency with tries, suffix-related structures, inverted indexes, and time/space complexity trade-offs.

|Home/Coding & Algorithms/Instacart
Instacart logo
Instacart
Sep 6, 2025, 12:00 AM
mediumSoftware EngineerTake-home ProjectCoding & Algorithms
6
0

Implement data structures and APIs to store file names and support efficient queries that match both a given prefix and suffix. Provide methods add(name: string) and find(prefix: string, suffix: string) -> list of names (or IDs) that match both constraints, returning results in lexicographic order. Support up to 100,000 insertions and many queries with near-real-time updates; analyze time and space complexity and discuss alternatives (e.g., two tries, suffix automaton, inverted indexes).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...